mercredi 24 janvier 2018

how to check if the variable is null?

I know this doesnt work but how can I know if the user added even one char?

public class Program
import java.util.Scanner;
{
public static void main(String[] args) {
    Scanner a = new Scanner(System.in);
    String b = a.nextLine();

//I know this doesnt work but how can I know if the user added even one char?
    if (b!=null){
    System.out.println(b);
}
}
}

Aucun commentaire:

Enregistrer un commentaire