Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By somers

Thread: Newbee stumped

  1. #1
    somers is offline Member
    Join Date
    Sep 2016
    Rep Power

    Default Newbee stumped

    I'm taking the Solo learn java tutorial using Ellipse. In the Creating Classes & Objects.
    So far, I have:

    public class Animal {
    void bark() {

    Then, they say: Let's head over to our main and create a new object of our class.
    This looks like:

    class MyClass {
    public static void main(String[ ] args) {
    Animal dog = new Animal();

    How do I get the class MyClass in this program. If I enter new class though the src, I lose the top portion of the program... and how do I show the total program on the same page?
    I"m definately doing something wrong...Remember... I said Newbee

    Thanks... Steve
    Kwemboi eric likes this.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Newbee stumped

    If you say new class, you create a new class in a different file. If you want to put a new class in the same file then just type
    it in after the first class.

    BTW, classes declared public must be in a file by the same name with a .java suffix. This should be taken care of by
    Eclipse. I recommend in your example you make MyClass public in its own file. This will make it easier to find the entry
    point (main). Then the Animal class can be either in the same file or its own file.

    Last edited by jim829; 09-10-2016 at 01:16 AM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    somers is offline Member
    Join Date
    Sep 2016
    Rep Power

    Default Re: Newbee stumped

    Thanks, Jim. Is there a way, I view them both together on the same page? Solo learn should have explained it something like you did. I thought perhaps that I'd have to right-click on 'public class animal' and create a class from there. Especially confusing for people absolutely new to elipse,,, and Java.

    Thanks... Steve

Similar Threads

  1. I'm stumped
    By Budnnet in forum New To Java
    Replies: 5
    Last Post: 03-04-2014, 09:10 AM
  2. Stumped on unknown problem
    By stevenfriz in forum New To Java
    Replies: 9
    Last Post: 02-16-2012, 09:55 AM
  3. Stumped... any help would be appreciated!
    By gard007 in forum New To Java
    Replies: 3
    Last Post: 12-01-2011, 07:42 AM
  4. NewBee
    By funnnyfarm in forum New To Java
    Replies: 1
    Last Post: 01-10-2011, 06:26 AM
  5. stumped......
    By trueblue in forum New To Java
    Replies: 21
    Last Post: 07-13-2009, 04:16 PM

Posting Permissions

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