now i'm writing a method which is checking the ip already exist or not

private boolean EXISTIP(String s) {
		boolean result = true;
		try{
			for (int i = 0; i < Client_list.length; i++) {
				if (Client_list[i][0].equals(s)) {
					return true;
				} else {
					result = false;
				}
			}
		}catch(Exception e){
			return false;
		}
		return result;
	}

can you check it?
it does not return anything to me

now i'm writing a method which is checking the ip already exist or not

private boolean EXISTIP(String s) {
		boolean result = true;
		try{
			for (int i = 0; i < Client_list.length; i++) {
				if (Client_list[i][0].equals(s)) {
					return true;
				} else {
					result = false;
				}
			}
		}catch(Exception e){
			return false;
		}
		return result;
	}

can you check it?
it does not return anything to me

hmm i cant see why not, when you say it doesnt return anything ... are you saying the value is null? could you perhaps post the call you make to the method, and the code you use to check the result from the method? I am a bit confused though why do you have a try catch? because if there is a null value in the array its going to return false even if a value did exist later in the array
and i think declaring the boolean result is not needed ... just return true in the if statement skip the else and at the end of your code return false. because if it does reach the end of your method/code then no value existed, my idea would look like this:

private boolean EXISTIP(String s) {
        for (int i = 0; i < Client_list.length; i++) {
            if (Client_list[i][0] != null) {
                if (Client_list[i][0].equals(s)) {
                    return true;
                } 
            }
        }
        return false;
    }

Edited 4 Years Ago by DavidKroukamp: n/a

maybe your list has so many elements so it seems to be an endless loop.
add a print in your method before your loop, and print that size, it's a long shot, but makes more sense than: doesn't return anything.

either it never reaches one of the result statements, or it throws an exception of which you haven't told us yet

This article has been dead for over six months. Start a new discussion instead.