I use Eclipse for programming and it tells me if want to output the "Input String"
Cannot make a static reference to the non-static field Input
Why has the variable to be static in the finally-block?
import java.util.Scanner;
public class NameSort {
String Input;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
try {
System.out.println("Inupt some Text");
while (sc.hasNextLine()){
String Input = sc.nextLine();
System.out.println(Input);
if (Input.toLowerCase().equals("ende")) {
System.exit(0);
sc.close();
}
}
} finally {
if (sc != null)
sc.close();
System.out.print(Input);
}
}
}