Landing : Athabascau University

Questions Neglected in the COMP268 Forum

  • Public
By David Langer March 16, 2014 - 9:17am

Getting replies for Java programming questions and observations in the online COMP268 forum seems to be an issue. One student quoted a popular song, "Is there anybody out there?". Where is the author, for example, of the online Study Guide? Or was it assembled robotically? 

Here's a question, among others we've asked, relating to Java programming and the online Study Guide, so far without any replies or attention whatsoever (2014 03 16):

Online Study Guide Unit 1 A Quick Introduction to String Objects and String Methods: 

This animation highlights string objects and methods used by string objects. Here we deal with two string objects and a number of string methods that are employed on these two objects.

To start the animation [a flash animation, depicted in the pic below], first type in two strings. These two strings correspond to two String class objects named string1 and string2. They can be identical or different. When you press Start, a two-column table will be displayed.

However, selecting the string1.equals(string2) method for null on both strings yields "true" in this [Study Guide] flash animation. 

But apparently invoking an equals() on a null gives a NullPointerException,

if you invoke .equals() on null you will get NullPointerException

So it is always advisble to check nullity before invoking method where ever it applies

answered Dec 21 '10 at 15:49 Jigar Joshi

and,

In Java 0 or null are simple types and not objects.

answered Dec 21 '10 at 15:55 user523859 

http://stackoverflow.com/questions/4501061/java-null-check-why-use-instead-of-equals

The Java API for equals() states that,

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values [my bolding] x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

http://download.java.net/jdk8/docs/api/java/lang/Object.html#equals-java.lang.Object-

One Java apparent professional has stated that the equals() method is broken in Java, and recommends using another library completely:

http://functionaljava.googlecode.com/svn/artifacts/3.0/javadoc/fj/Equal.html

Note: because this forum (The Landing) only links to image urls, I am uploading my pic of the online study guide for COMP268 elsewhere, and then linking to it.