Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2004

Tip: Looking for answers? Try searching our database.

SimpleInput Class

Thread view: 
Rowan B - 01 Nov 2004 19:29 GMT
OK, so I'm a complete idiot of a java newbie that's just started computer
science at university and my first project is causing me a lot of problems.
In particular, I'm struggling to use the SimpleInput class. I always seem to
get a cannot resolve symbol error message where the symbol is 'class
SimpleInput' when I try to use it. I get this message when I try to compile
the code shown at this website:
http://www.csse.monash.edu.au/courseware/cse1202/html/write_a_complete_class
.html

Can someone please explain to me why it doesn't work? Also can anyone
explain as simply as possible how to use arrays and maybe show some simple
code that uses an array?
Oscar kind - 01 Nov 2004 21:45 GMT
> I always seem to
> get a cannot resolve symbol error message where the symbol is 'class
> SimpleInput' when I try to use it. I get this message when I try to compile
> the code shown at this website:
> http://www.csse.monash.edu.au/courseware/cse1202/html/write_a_complete_class.html

As I see it, the class SimpleInput is not mentioned in an import
statement, thus it should be in the default package. Do you have a file
SimpleInput.java or SimpleInput.class in the same directory as Dog.java
(the class whose source you refered to)?

If not, that's your problem: the code references a class that doesn't
exist. Ask your instructor how to get it to work.

> Also can anyone explain as simply as possible how to use arrays and maybe
> show some simple code that uses an array?

Read the chapter in your course book that handles arrays. Then, look at
following code snippet and read the relevant parts again. Make sure you
understand what it does, and answer all "why" questions. After this you'll
know how to create and use arrays. Perfectly but for the practice.

    // Warning: this code snippet does not compile. This is intentional.

    int[] intArray; // A reference to an array of int values.

    intArray = new int[3]; // Now it actually points to an array.

    System.out.println(intArray[0]); // OK. Why?
    System.out.println(intArray[1]); // Prints 0; Why?
    System.out.println(intArray[2]);
    System.out.println(intArray[3]); // IndexOutOfBoundsException. Why?

    intArray = new int[]{1,2,3}; // Alternative array creation.
    System.out.println(intArray[0]); // Prints 1
    System.out.println(intArray[1]); // Prints 2
    System.out.println(intArray[2]); // Prints 3; Why?

    intArray = new Integer[54]; // Compiler error. Why?
    intArray = new long[3]; // Compiler error. Why?

    Integer[] integerArray = new Integer[3];
    // Why does the following not work?
    System.out.println(intArray[0].intValue()); // NullPointerException.

    // This results in a compiler error for any Java version before 1.5.0.
    // Why? (hint: autoboxing)
    integerArray = new Integer[] {1,2,3};

    integerArray = new Integer[] {
        new Integer(1),
        new Integer(2),
        new Integer(3)
    }; // Alternative difinition.
    integerArray[1] = new Integer(5);

    for (int i=0; i<integerArray.length; i++) {
        System.out.println(String.valueOf(integerArray[i]));
    }

Signature

Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2

Rowan B - 02 Nov 2004 01:21 GMT
> > I always seem to
> > get a cannot resolve symbol error message where the symbol is 'class
> > SimpleInput' when I try to use it. I get this message when I try to compile
> > the code shown at this website:

http://www.csse.monash.edu.au/courseware/cse1202/html/write_a_complete_class
.html

> As I see it, the class SimpleInput is not mentioned in an import
> statement, thus it should be in the default package. Do you have a file
[quoted text clipped - 3 lines]
> If not, that's your problem: the code references a class that doesn't
> exist. Ask your instructor how to get it to work.

Thanks, I downloaded the SimpleInput code and created a SimpleInput class
within the Dog project and it worked. However, I couldn't work out how to
use the import command to do it.

> > Also can anyone explain as simply as possible how to use arrays and maybe
> > show some simple code that uses an array?
[quoted text clipped - 41 lines]
> System.out.println(String.valueOf(integerArray[i]));
> }

That looks helpful, thanks a lot.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.