Forum Stats

  • 3,767,917 Users
  • 2,252,729 Discussions


How to subtract from the total length of an array

Gayathri Venugopal
Gayathri Venugopal Member Posts: 108
edited Feb 24, 2019 3:10PM in Java User Groups Discussions

I have an array named shop which has a length of 10. char shop[][] = new char[10][10] so my shop.length is 10 if (colshop ==  9) In the above line, I have hard-coded the value to be 9, Instead, I want to subtract 1 from shop.length. If I do if (colshop == (shop.length - 1)) ,it is not working.Please be patient as I am new to java. How do I do it so that I get the value of 9 as i do not want to hard code the value 9