Good evening all,
Probably a simple fix but I just cannot find it. I made this to print out every second chr from a string:
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string:");
String input = sc.next();
String total = "";
for (int i = 0; i < input.length(); i += 2){
total += input.charAt(i);
}
System.out.println(total);
It works like a charm, but the '+=' is highlighted and gives me the tip: string concatenation in loop. Am I using a wrong method to accomplish what I want?