1:33 pm - Saturday March 25, 2017

Program used to returns true object using Boolean equals(Object obj) method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

 

The java.lang.Boolean.equals(Object obj) returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.

EXAMPLE PROGRAM


public class BooleanEqualsbyObject {
	public static void main(String[] args) {

		Boolean b1, b2;

		Boolean result;

		b1 = new Boolean(true);
		b2 = new Boolean(false);

		result = b1.equals(b2);

		String str = "b1:" + b1 + " and b2: " + b2 + " is equals: " + result;
		// System.out.println("b1:"+b1+" and b2: "+b2+" is equals: "+result);
		System.out.println(str);
	}

}

 

Output:  b1:true and b2: false is equals: false

Explanation:

The java.lang.Boolean.equals(Object obj) returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.

Parameter: obj – the object to compare with

Return:

This method returns true if the Boolean objects represent the same value, false otherwise.

Throws: NA

 

BACK

 

Filed in: Z-A All Java Codes

Comments are closed.