General Java Questions II
}
Then, in your method create one of these, set the corresponding values,
and return it.
MyObj yourMethod() {
MyObj obj = new MyObj()
obj.myInt = 20;
obj.myDouble = 1.0003
return obj;
}
Q: How do I use object serializtion for an object that has other objects as data
member? Do both the class need to implement serialize?
How about static data?
class A{
}
class B{
public A a;
}
Answer: Both the object and all the object references it contains need to belong to
classes that implement Serializable.
Static and transient fields are not serialized. For more, see,
http://java.sun.com/docs/books/tutorial/essential/io/serialization.html
I recently learned a bit about "inner classes" but this seems to be different...
Q: I m a bit new to Java programming so bear with me. My employer bought a
package of java graphics library programs to support some chart applets
we want to create. We have the source code. I m trying to create a jar
file with all the files I need to run the applet. When I currently run
the applet, the browser java tool says that it can t find
"TextComponent$1.class". I recently learned a bit about "inner classes"
but this seems to be different. The "TextComponent.java" file does
contain some inner classes, but not a class called "1". I m confused.
Is this an inner class? Or is it something else. Any help would be
appreciated. Thanks...
Answer: The TextComponent$1.class is the first anonymous class defined in
TextComponent.java. Since nested (inner) classes are compiled to their own
.class file, they needed unique names. The javac compiler is just creating a
unique file name for an anonymous nested class.
Hi there, does anybody know a good source of design patterns written in JAVA ?
Answer: A pretty good (free to download) book.
http://www.patterndepot.com/put/8/JavaPatterns.htm
Q: Whats the difference between the two: System.err. and System.out? When
should we use System.err?
Answer1: System.out leads the output to the standard output stream (normally
mapped to your console screen), System.err leads the output to the standard error
file:///F|/a_jsite/350_tips/general_java II.htm (4 of 14) [2001 07 08 11:24:53]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved