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

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

java - Incorrect order of records in M-M relationship in hibernate -