lundi 11 septembre 2017

How did the int variable get initialize without a value

In this the Choose variable needs to be initialized, a value needs to be added.

Int choose;
If(choose==1){
//Do something
}

While this a value is not added and it still works.

Int choose;
Scanner userinput=new Scanner(System.in);
Choose=userinput.nextInt();
If(choose==1){
//Do something
}

Is it because of

.nextInt();

Aucun commentaire:

Enregistrer un commentaire