java - How can I check whether the variable have value or not? -
i new java
.might it's simple question,but didn't it.
i have variable, want check whether variable have value or not.for wrote following code.but every time showing false
output.
public class stringoperations { public static void main(string[] args){ boolean b=new boolean("t87778rue"); int = 10; system.out.println(b.equals(i)); } }
you're creating boolean object representing false value, because string parameter not "true" (ignoring case).
boolean b=new boolean("t87778rue");
next, check whether boolean object representing false equal 10. it's not.
int = 10; system.out.println(b.equals(i));
from boolean constructor api documentation:
boolean(string s) allocates boolean object representing value true if string argument not null , equal, ignoring case, string "true".
Comments
Post a Comment