This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi ppls how are you doing?
Im trying to expose some of my own types using the 'put' method from the java Script Engine but its guive-me a error. See my code:
See, the Actor class is a custom class of mine so when I try to use getY() method java return an error tell me that the method does not exists. Whats wrong ? Can I use my own object or only the java native ones?
Thanks in advance!
Its weird because my Actor class is on the same package com.xcretor and the method getX() is public. Im getting this error:
Its really weird....
Here is my actor class:
Vinicius Souza wrote:Its weird because my Actor class is on the same package com.xcretor and the method getX() is public.
Yes, but this is about the getY method, not the getX method.
And looking at your code, the getX and getY methods are not public, they have default access.
You're writing in a kind of C++-style. Specifying access specifiers in Java does not work the same as in C++. Look at this:
Do you understand what's happening here? Only the variable x has private access. All the other variables have default access. The indentation you've used is misleading - as if all the variables are private. This is the same as:
You are doing the same with the constructor and methods:
The constructor is public, but all the methods have default access.
You have to specify private or public for all variables and methods separately.