Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

Java Objects and Collections

Share this post!
 Vote this!

Everything in Java apart from primitive data types are Objects, every exception, every event, every array extends from java.lang Object.
toString() method
When you want a to read something more meaningful about an object of your own class you can override the toString() method.

overriding toString() example
 
public class myTest() {
   String classInfo = "This is my new class that overrides the toString method";

   public String toString() {
      return ("This is some information about myTest class" + classInfo);
   }
more...

0 comments:

Post a Comment