Explain testing objects for equality in java, JAVA Programming

Assignment Help:

Explain Testing Objects for Equality in java?

<, >, <= and >= can only be used with numbers and characters. They cannot be used with Strings, booleans, arrays or other compound types since there's no well-defined notion of order for these objects. Is true greater than false? Is "My only regret is that I have but one life to give for my country" greater than "I have a dream"?

Equality is a little easier to test however. true is equal to true and true is not equal to false. Similarly "My only regret is that I have but one life to give for my country" is not equal to "I have a dream." However you might be surprised if you ran this program:
class JackAndJill {

public static void main(String args[]) {

String s1 = new String("Jack went up the hill.");
String s2 = new String("Jack went up the hill.");

if ( s1 == s2 ) {
System.out.println("The strings are the same.");
}

else if ( s1 != s2 ) {
System.out.println("The strings are not the same.");
}
}
}
The result is
The strings are not the same.


Related Discussions:- Explain testing objects for equality in java

A simple desktop software, A simple Desktop Software Project Description...

A simple Desktop Software Project Description: We want a tool that could convert Flash Games into HTML5 Files. These are not tedious games, very simple game. I have attached

Need android - ios pdf reader, Project Description: Our project consists...

Project Description: Our project consists of a plain application, both for iPad/iOS (Newsstand app) and Android 4.x which will download PDF magazines from the internet, after ha

Websphere - weblogic, WebSphere - Weblogic and Apache: Building/Ins...

WebSphere - Weblogic and Apache: Building/Installation  and maintenance of Solaris and Linux machines. Exposure to Sun Hardware : Sunfire v880,v890.V440,X4600

File handling operation, Write a program called Drivers that displays infor...

Write a program called Drivers that displays information about Formula 1 drivers and their teams.     The program starts by prompting (asking) the user for the name of an input tex

Java script, var temp =14; var y = 2; temp document.write(temp);

var temp =14; var y = 2; temp document.write(temp);

Program for users to play the game of brick, Task Your task is  to  w...

Task Your task is  to  write  a  Java  program  that  allows  users  to  play  the  game  of  Brickles. (note:  it  is  up  to  you  whether  to  use the  skeleton).  The prog

What is jdbc exactly, What is JDBC exactly? Describe the steps required to ...

What is JDBC exactly? Describe the steps required to execute a SQL query using JDBC.

What is the difference between SOA and a Web Service, Normal 0 ...

Normal 0 false false false EN-US X-NONE X-NONE

Explain function arguments with the help of an example, Explain function ar...

Explain function arguments with the help of an example? Arguments on a function are comma separated list of data enclosed within braces. It describes interface among the web pa

Object diagrams, Object diagrams define instances instead of classes. They ...

Object diagrams define instances instead of classes. They are useful for illustrating some complicated objects in detail about their recursive relationships.     When

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd