Java - How to make this a horizontal statement with a newline. Whenever I use System.out.println, it makes the output vertical instead of horizontal. What am I doing wrong? Program below. import java.util.Scanner; public class LabProgram { public static void main(String[] args) { int i; String InputString; Scanner sc = new Scanner(System.in); InputString = sc.nextLine(); char[] strArray = new char[InputString.length()]; for(i = 0; i < InputString.length(); i++){ strArray[i] = InputString.charAt(i); } for(i = 0 ; i< InputString.length() ; i++) if(strArray[i] >= 'a' && strArray[i] <= 'z' || strArray[i] >= 'A' && strArray[i] <= 'Z') System.out.print(strArray[i]); (the problem line) } }
Java - How to make this a horizontal statement with a newline. Whenever I use System.out.println, it makes the output vertical instead of horizontal. What am I doing wrong? Program below.
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
int i;
String InputString;
Scanner sc = new Scanner(System.in);
InputString = sc.nextLine();
char[] strArray = new char[InputString.length()];
for(i = 0; i < InputString.length(); i++){
strArray[i] = InputString.charAt(i);
}
for(i = 0 ; i< InputString.length() ; i++)
if(strArray[i] >= 'a' && strArray[i] <= 'z' || strArray[i] >= 'A' && strArray[i] <= 'Z')
System.out.print(strArray[i]); (the problem line)
}
}

Step by step
Solved in 2 steps with 2 images









