Re: Cannot find symbol java error (newbie question)
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 15:24:22 -0400
Daniel Pitts wrote:
Look at this SSCCE:
class MyClass {
Integer[] array = new Integer[10];
public void doSomething() {
array.intValue(); /* fails, calling on the array instead of the
element */
array[0].intValue(); /* succeeds */
for (int i = 0; i < array.length; ++i) {
System.out.println(array[i].intValue()); /* succeeds */
}
}
}
These calls marked "succeeds", while they successfully compile, only succeed at runtime if each invoked array element is non-null.
This is not relevant to the compilation issue but might be important to those who forget that newsgroup examples sometimes intentionally omit details for pedagogical purposes that would be problematic in actual production. In production code one would anticipate a NullPointerException.
--
Lew
.
- References:
- Cannot find symbol java error (newbie question)
- From: Taria
- Re: Cannot find symbol java error (newbie question)
- From: Daniel Pitts
- Cannot find symbol java error (newbie question)
- Prev by Date: Re: Singly Linked LIst and Objects Newbie Question
- Next by Date: Re: OT: Unicode and vi(m). Was Re: Great SWT Program
- Previous by thread: Re: Cannot find symbol java error (newbie question)
- Next by thread: Method.invoke() with one arg compiles despite method signature
- Index(es):
Relevant Pages
|
|