Results 1 to 4 of 4
  1. #1
    haiforhussain is offline Member
    Join Date
    Jun 2008
    Posts
    11
    Rep Power
    0

    Default system.out.prinln

    Can anyone explain this ...
    I know that System is a class , out is an outputstream reference ... println is an static method ...
    if i want to create like Cassname.OutputStrreamRef.StaticMethod ...
    how should i implement this ???...
    pls clarrify this ....

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    You want to implement your own class and static method to do the process in that class. Try and see.

  3. #3
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default Class atributes

    Hello haiforhussain

    Define your class to have a null referenced object as a static attribute and have the class of that attribute implement a static method. For example:

    Java Code:
    public class ClassOne{
        public static ClassTwo two = null;
    }
    And
    Java Code:
    public class ClassTwo{
        public static void doSomething(){
            System.out.println("In the past I was a grasshopper. But now, I am the master!");
        }
    }
    Then the following could be done:
    Java Code:
    public static void main(String[] arg){
    	ClassOne.two.doSomething();
    }
    This could be nice if you want to build a toolbox, i.e., you don't want to add objects to your project, but structured functionality. Personally, I have never found a need for this though. :)

    Good luck ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  4. #4
    haiforhussain is offline Member
    Join Date
    Jun 2008
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by tim View Post
    Hello haiforhussain

    Define your class to have a null referenced object as a static attribute and have the class of that attribute implement a static method. For example:

    Java Code:
    public class ClassOne{
        public static ClassTwo two = null;
    }
    And
    Java Code:
    public class ClassTwo{
        public static void doSomething(){
            System.out.println("In the past I was a grasshopper. But now, I am the master!");
        }
    }
    Then the following could be done:
    Java Code:
    public static void main(String[] arg){
    	ClassOne.two.doSomething();
    }
    This could be nice if you want to build a toolbox, i.e., you don't want to add objects to your project, but structured functionality. Personally, I have never found a need for this though. :)

    Good luck ;)
    hi tim
    Ur answer is really good .... Now I have understood....
    Thanx a lot

Similar Threads

  1. Point System
    By Zosden in forum Suggestions & Feedback
    Replies: 2
    Last Post: 02-14-2009, 12:45 PM
  2. Getting System Properties
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-19-2007, 05:00 PM
  3. system information
    By nitinborge5 in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 09:25 AM
  4. where is the system.property
    By osval in forum Advanced Java
    Replies: 2
    Last Post: 08-06-2007, 03:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •