J
Jochen Brenzlinger
Assume I have an array of Strings like:
String[] part = .....;
If I try to access e.g. the 5th part and it does not exist then java crashes with an Indexouitofbounds exception.
How can I most easily check (in a bigger logical expression) whether the 5th slot exist?
The following does not work:
if (part[4].exist() && part[4].equals("hello")) {
....
}
This does not work either:
if (part[4].length() > 0 && part[4].equals("hello")) {
....
}
So what else can I use?
Jochen
String[] part = .....;
If I try to access e.g. the 5th part and it does not exist then java crashes with an Indexouitofbounds exception.
How can I most easily check (in a bigger logical expression) whether the 5th slot exist?
The following does not work:
if (part[4].exist() && part[4].equals("hello")) {
....
}
This does not work either:
if (part[4].length() > 0 && part[4].equals("hello")) {
....
}
So what else can I use?
Jochen