Results 1 to 3 of 3
  1. #1
    GreenTea1984 is offline Member
    Join Date
    Jun 2015
    Posts
    1
    Rep Power
    0

    Default Help with Multiple Classes, Objects, and Methods in Java

    Hi, I'm learning Java programming through a Youtube video. Int his video the topic is multiple classes, objects, and methods. In the video I was told to go into my IDE (Netbeans), to create a new class call tuna from my source package and name the newly created class tuna. So now I have two .java file types; one is MultipleClasses which contains my main method and the newly created class and method call simpleMessage in tuna.java.

    Here is the class containing my main method call MultipleClasses.java file:

    package multipleclasses;

    public class MultipleClasses {

    public static void main(String args[]) {

    tuna tunaObject = new tuna();
    tunaObject.simpleMessage();
    }

    }

    Here is my newly created class tuna.java file:

    public class tuna {

    public void simpleMessage() {
    System.out.println("This is another class");
    }

    }


    When I follow the video I input the code exactly and checked it for spelling or syntax errors, and I run the code in my Netbeans IDE I get this error build message;

    run:
    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class tuna
    location: class multipleclasses.MultipleClasses
    at multipleclasses.MultipleClasses.main(MultipleClass es.java:11)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    What is going on here? I followed the instructional video exactly. How did it work for him, vene though he was using Eclipse?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Help with Multiple Classes, Objects, and Methods in Java

    Since their are no import statements I would presume tuna is in the same package. So put the same package definition in your tuna class. Also,
    by convention class names begin with uppercase letters. Variables and methods with lower case letters. Check out my signature for more on Java naming conventions.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Help with Multiple Classes, Objects, and Methods in Java

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Java Objects and Classes
    By njcountrygirl in forum New To Java
    Replies: 3
    Last Post: 03-15-2015, 06:09 PM
  2. how to use get and set methods for multiple classes
    By comptechgivinsky in forum New To Java
    Replies: 3
    Last Post: 11-06-2012, 05:14 PM
  3. Replies: 1
    Last Post: 09-09-2011, 06:57 PM
  4. Java project with multiple classes
    By trakke in forum New To Java
    Replies: 1
    Last Post: 04-28-2011, 08:16 PM
  5. java question on classes & objects
    By joe98 in forum New To Java
    Replies: 16
    Last Post: 04-08-2011, 09:45 AM

Tags for this Thread

Posting Permissions

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