If...else in java


I was expecting to write the “filename” in the console, but it prints else condition(ignoring if).

??? why doe

what?

You’re misunderstanding the difference between console input and command-line arguments; you should look them up.

class StringExample
{
public static void main(String[] args) {
String s = “”;
if(args[0].length() == 1)
{
s = args[0];
System.out.println(“Hello”);
System.out.println(args[0].length());
}
else
{
System.out.println(“Hello dear”);
}
}
}

you should provide command line argument while running this.