> 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.