Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Hey guys!!

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Location
    Hungary
    Posts
    1
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hey guys!!

    I am Tamas from Hungary. I am beginner java developer and i have got a little problem with inheritance. My source code:

    package oroklodes;
    class MyClass {
    private int anInt=4;
    public String toString() {
    return "Instance of myClass.anInt"+anInt;
    }
    public static void main(String[] args) {
    MyClass act = new MyClass();
    act.toString();

    }
    }

    The program is not working because i get an error message!! The message is:

    Error: Could not find or load main class oroklodes.MyClass

    I would be happy if somebody knew the solution.


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts
    Last edited by jps; August 7th, 2012 at 01:37 PM.

  3. #3
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,104
    Thanks
    169
    Thanked 780 Times in 726 Posts
    Blog Entries
    5

    Default Re: Hey guys!!

    Thread moved from Members Introductions

  4. #4
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hey guys!!

    Hi,
    Your source code is correct,but error is in package name....You remove the first line in your code "package oroklodes;".....
    I check its Executed....


    class MyClass {
    private int anInt=4;

    public String toString() {
    System.out.println("2");
    System.out.println(anInt);
    return "Instance of myClass.anInt"+anInt;

    }
    public static void main(String[] args) {
    MyClass act = new MyClass();
    System.out.println("1");
    act.toString();

    }
    }

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Hey guys!!

    Could you post the contents of the terminal/console for when you tried to execute the program that shows what directory you are in, the commandline you entered and the error message.

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. hi guys
    By vitaliz in forum Member Introductions
    Replies: 2
    Last Post: July 20th, 2012, 04:48 AM
  2. HI guys
    By nchmurali in forum Member Introductions
    Replies: 2
    Last Post: December 15th, 2011, 01:43 AM
  3. hi guys
    By Diana_Diana89 in forum Member Introductions
    Replies: 1
    Last Post: November 30th, 2011, 11:32 AM
  4. Hi all guys!
    By mauri23 in forum Member Introductions
    Replies: 1
    Last Post: November 19th, 2011, 10:33 AM
  5. Hello guys!
    By hopkins23 in forum Member Introductions
    Replies: 1
    Last Post: October 26th, 2011, 09:40 AM