0
Can you use string as a condition in a if statement?
4 Réponses
+ 4
You can do somthing like.
//create a variable to hold a string value
String str = "jason";
//as strings are objects we can use its methods
//one of its methods is .equals() this returns a
//boolean if true the statement will execute
if(str.equals("jason"){
System.out.print("hi my name is "+str);}
+ 1
I see, thanks. :)
+ 1
Jason Cuerbo your welcome, I have commented the code so you can see what's happening.
+ 1
Thanks again heheh, I understand now xD