java - How to check null condition for the boolean variable -
i have class shown
package com; public class person { boolean registered; public boolean isregistered() { return registered; } public void setregistered(boolean registered) { this.registered = registered; } }
the data person object set based on data present in db . problem older records registered filed not present .
so how can test if filed present or not ??
package com;
public class test { public static void main(string args[]) { person per = new person(); if (per.isregistered()) { } } }
how can check if per.isregistered() field present or not person object ??
boolean
primitive data type can not null, can true or false. boolean
object rapper of boolean data type, null , boolean.true
, boolean.false
;
public class person { boolean registered; ... }
...
person per = new person(); if (per.isregistered()!=null ) { if(!per.isregistered()){ ... }else{ ... } }
Comments
Post a Comment