Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
General <strong>Java</strong> Questions II<br />
Answer: You could make a new object/class that contains these two values and<br />
return it. For example:<br />
Define an object like this:<br />
class MyObj {<br />
public int myInt;<br />
public double myDouble;<br />
}<br />
Then, in your method create one of these, set the corresponding values,<br />
and return it.<br />
MyObj yourMethod() {<br />
MyObj obj = new MyObj()<br />
obj.myInt = 20;<br />
obj.myDouble = 1.0003<br />
return obj;<br />
}<br />
Q: How do I use object serializtion for an object that has other objects as data<br />
member? Do both the class need to implement serialize?<br />
How about static data?<br />
class A{<br />
}<br />
class B{<br />
public A a;<br />
}<br />
Answer: Both the object and all the object references it contains need to belong to<br />
classes that implement Serializable.<br />
Static and transient fields are not serialized. For more, see,<br />
http://java.sun.com/docs/books/tutorial/essential/io/serialization.html<br />
I recently learned a bit about "inner classes" but this seems to be different...<br />
Q: I'm a bit new to <strong>Java</strong> programming so bear with me. My employer bought a<br />
package of java graphics library programs to support some chart applets<br />
we want to create. We have the source code. I'm trying to create a jar<br />
file with all the files I need to run the applet. When I currently run<br />
the applet, the browser java tool says that it can't find<br />
"TextComponent$1.class". I recently learned a bit about "inner classes"<br />
but this seems to be different. The "TextComponent.java" file does<br />
contain some inner classes, but not a class called "1". I'm confused.<br />
Is this an inner class? Or is it something else. Any help would be<br />
appreciated. Thanks...<br />
Answer: The TextComponent$1.class is the first anonymous class defined in<br />
TextComponent.java. Since nested (inner) classes are compiled to their own<br />
.class file, they needed unique names. The javac compiler is just creating a<br />
unique file name for an anonymous nested class.<br />
Hi there, does anybody know a good source of design patterns written in JAVA ?<br />
Answer: A pretty good (free to download) book.<br />
file:///F|/350_t/350_tips/general_java-II.htm (4 of 13) [2002-02-27 21:18:24]