java - How to test whether a position in an array exists -
i trying test whether char[i] exists. example:
char[] c = {'h', 'e', 'l', 'l', 'o'}; positions 0 - 4 exist following results in error:
system.out.println(c[5]); essentially, how can return boolean true if c[i] exists , false if not?
try
int = 5; boolean exists = c.length >= - 1; because of char can not hold null value, there no non-existing character in between.
Comments
Post a Comment