By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

Passing objects (not stones)

P: n/a
I'm using NetBeans 3.5.1. Why doesn't this work?
Referenced class:

public class MyClass {

...
...

// All sorts of methods in here that work

...
...
public Object objectForValue(int i) {
// test code
Object o = "objectForValue";
return o;
}
}

Here's where the error is:

public class MyOtherClass {

...
...

// All sorts of methods in here that work

...
...

public Object getObjectTest(int i) {
// test code
MyClass mine = new MyClass();
Object o = mine.objectForValue(i); <<== ERROR
return o;
}

}

The error I get is:

myTestModel.java [40:1] cannot resolve symbol
symbol : method objectForValue (int)
location: class MPNode
Object o = mine.objectForValue(i);
I intially just had the getObjectTest method as:

public Object getObjectTest(int i) {
MyClass mine = new MyClass();
return mine.objectForValue(i);
}

but that didn't work either. It gave the same error.

Apparently there is something about the Object class that I don't
understand. Could someone enlighten me?
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"NotAsDumbAsILook" <to************@yahoo.com> wrote in message
news:e3**************************@posting.google.c om...
I'm using NetBeans 3.5.1. Why doesn't this work?
Referenced class:

public class MyClass {
public Object objectForValue(int i) {
// test code
Object o = "objectForValue";
return o;
}
}

Here's where the error is:

public class MyOtherClass {
public Object getObjectTest(int i) {
// test code
MyClass mine = new MyClass();
Object o = mine.objectForValue(i); <<== ERROR
return o;
}
}

The error I get is:

myTestModel.java [40:1] cannot resolve symbol
symbol : method objectForValue (int)
location: class MPNode
Object o = mine.objectForValue(i);
I intially just had the getObjectTest method as:

public Object getObjectTest(int i) {
MyClass mine = new MyClass();
return mine.objectForValue(i);
}

but that didn't work either. It gave the same error.

Apparently there is something about the Object class that I don't
understand. Could someone enlighten me?


Unless I'm missing something, that code is fine. But you haven't posted code
that demonstrates your problem. See for suggestions:
http://www.physci.org/codes/sscce.jsp

Then post some actual executable code.
Jul 17 '05 #2

P: n/a
to************@yahoo.com (NotAsDumbAsILook) wrote in message news:<e3**************************@posting.google. com>...
I'm using NetBeans 3.5.1. Why doesn't this work?
Referenced class:

public class MyClass {

...
...

// All sorts of methods in here that work

...
...
public Object objectForValue(int i) {
// test code
Object o = "objectForValue";
return o;
}
}

Here's where the error is:

public class MyOtherClass {

...
...

// All sorts of methods in here that work

...
...

public Object getObjectTest(int i) {
// test code
MyClass mine = new MyClass();
Object o = mine.objectForValue(i); <<== ERROR
return o;
}

}

The error I get is:

myTestModel.java [40:1] cannot resolve symbol
symbol : method objectForValue (int)
location: class MPNode
Object o = mine.objectForValue(i);
I intially just had the getObjectTest method as:

public Object getObjectTest(int i) {
MyClass mine = new MyClass();
return mine.objectForValue(i);
}

but that didn't work either. It gave the same error.

Apparently there is something about the Object class that I don't
understand. Could someone enlighten me?


Wha, wha, wha, what is class MPNode? Isn't it the real problem?
Jul 17 '05 #3

P: n/a
to************@yahoo.com (NotAsDumbAsILook) wrote in message news:<e3**************************@posting.google. com>...

The error I get is:

myTestModel.java [40:1] cannot resolve symbol
symbol : method objectForValue (int)
location: class MPNode
Object o = mine.objectForValue(i);

Oops! I was "simplifying" the code I posted and didn't rename that
MPNode as MyClass. That might be a little confusing.

Anyhoo, I figured out what the problem was, but I don't understand why
it was a problem. So, I'm going to alter the question.

Like I said before, I'm using NetBeans 3.5.1. I was putting together a
little sample application so that I could figure out how to make a
good TableClass while working with an ArrayList of Objects. Well, in
order to save time coding, I copied over the class MyClass from
another project I am working on using the NetBeans Filesystem Explorer
(you right-click, copy, and then paste-as-copy in the new Filesystem).
Apparently there is something in the background that was giving
NetBeans grief. I could declare a new MyClass() object, and then use
the Code Completion to see the methods and variables in it. But, when
it came to compile time, the compiler couldn't see those methods, so
it was giving the "cannot resolve symbol" error.

I vaguely remembered seeing a similar problem with Delphi a few years
ago, and I tried a similar fix I used then. I created a new class
inside of the Filesystem I was working in - by doing a right-click,
new, java class. Then I cut and pasted the code from the original
MyClass into this new one, and referenced it instead of the old
MyClass object. Now the code complies just fine.

So, the error lies in copying a class from one filesystem into
another. I know that you normally wouldn't do that, but there is the
rare occasion where you would. Any thoughts?
Jul 17 '05 #4

P: n/a
"NotAsDumbAsILook" <to************@yahoo.com> wrote in message
news:e3**************************@posting.google.c om...
Oops! I was "simplifying" the code I posted and didn't rename that
MPNode as MyClass. That might be a little confusing.

Anyhoo, I figured out what the problem was, but I don't understand why
it was a problem. So, I'm going to alter the question.

Like I said before, I'm using NetBeans 3.5.1. I was putting together a
little sample application so that I could figure out how to make a
good TableClass while working with an ArrayList of Objects. Well, in
order to save time coding, I copied over the class MyClass from
another project I am working on using the NetBeans Filesystem Explorer
(you right-click, copy, and then paste-as-copy in the new Filesystem).
Apparently there is something in the background that was giving
NetBeans grief. I could declare a new MyClass() object, and then use
the Code Completion to see the methods and variables in it. But, when
it came to compile time, the compiler couldn't see those methods, so
it was giving the "cannot resolve symbol" error.

I vaguely remembered seeing a similar problem with Delphi a few years
ago, and I tried a similar fix I used then. I created a new class
inside of the Filesystem I was working in - by doing a right-click,
new, java class. Then I cut and pasted the code from the original
MyClass into this new one, and referenced it instead of the old
MyClass object. Now the code complies just fine.

So, the error lies in copying a class from one filesystem into
another. I know that you normally wouldn't do that, but there is the
rare occasion where you would. Any thoughts?

It depends on what exactly you're doing. If you're pasting into a
subdirectory of a mounted directory, your file is not in the classpath. It's
considered part of a Java package. Therefore you must have a package
statement in the source file and import the package in order to use class.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.