I have this code that takes the user input, the breaks it down into an array using.split() and then adds the only the values that are not" " to a list, normally when comparing lets say integers i would write == or != but how can i write does not equal to using.equals()? Do i write(!array.equals(" ");?
Scanner in = new Scanner(System.in);
String input = in.next();
String[] array = input.split("");
List<String> list = new ArrayList<String>();
for (int a = 0; a < array.length; a++) {
if (array[a].equals(" ")) {
list.add(array[a]);
}
}
!array[a].equals(" ")and yes.!array[a].equals(" ")should work.