|
If I run your code I get the following output:
testing.BaseTest$Student@1ad77a7
However, If I take Shivamkalra's advice and add a ToString() method to the Student class such as:
public String toString()
{
return "Name: " + name + ", " + family + " ID:" + studentId + "
}
I get the following output:
Name: ZZZ, WWW ID:3800
I must get a clever new signature for 2011.
|
|
|
|
|
st[1] is a object,not primitive type.So it need a print method.
from china
|
|
|
|
|
Hello
I am a beginner and practicing; I installed Netbeans and glassfish v3. then I went to file/new project and chose JavaEE/Enterprise application.in Servlet and setting option I add Glassfish but the finish buttun still disable.
do I have to do some setting for glassfish? do you have any ideas?
thanks
|
|
|
|
|
|
Hi,
I am searching one function to convert PDU formate to String in java
help me
Regards
Ashish Lad
|
|
|
|
|
And what is PDU format?
I must get a clever new signature for 2011.
|
|
|
|
|
I know PDU just as a Protocol Data Unit[^]
is this what you're thinking about?
And please explain your problem some more.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Hello All,
I have created a simple Web Service in Java, which has only one class containing 4 functions, Add, Subtract, Multiply and Divide. Now I want to publish this Web Service on Tomcat Server. I am able to do it on my Localhost through Eclipse.
Can please any one tell me how should I deploy this web service as a WAR on different server and how can I access this from another server/client. In short, where I can get the URL of the web service.
Any help in this regard is appreciated.
--Thanks
Sameer
|
|
|
|
|
|
Hello,
I need to know hot to use shift operators << and >> in Java with float and double types. I tried to use them but I got compile error. I needed it for serialization data e.g. sending over the streams.
|
|
|
|
|
I do not think that Java streams allow these operators, << and >> are shift operators which is why you get compile errors.
I must get a clever new signature for 2011.
|
|
|
|
|
Both Double and Float support the longValue() method which will return you a long primitive (if it's in the range of long). The other option for bit manipulation is to use the toHexString() method on Double or Float .
|
|
|
|
|
This may be a dumb question but what does bit shifting have to do with serialization? Why would you need to shift the bits in a double value in order to send it over a stream?
|
|
|
|
|
I think the OP is getting confused with the stream operators of C++.
I must get a clever new signature for 2011.
|
|
|
|
|
|
I'm assuming that you want to use the bit-representation of the floating point value with the shift operators to create a float from a byte-stream, and vice-versa
The java Float class (here[^]) contains functions:
floatToIntBits , floatToRawIntBits -- Convert from a float to an integer containing the float value's bit representation
intBitsToFloat : Converts an integer value (containing a float value's bit representation) to a Float variable.
So basically you can do something like:
byte[] data = ...;
int rdInt = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
float rdFloat = Float.intBitsToFloat(rdInt);
... And do the opposite to convert back from float to bytes.
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
Hi,
I installed Netbeans 6.9 and try to work on Java. at first glance I faced 2 questions?
when you open new project you see Java and java EE. what is the problem between them? what the meaning of enterprise Application?
I would please if some one who has experience help me in this matter.
|
|
|
|
|
Try the Java home page for more information on the different versions.
I must get a clever new signature for 2011.
|
|
|
|
|
'at a glance' is the keyword: Java EE at a glance[^]
Java EE @ Wikipedia[^]
So a Java-Project - is a general Java Application of some kind (not further defined).
A Java EE Project is a more specified project with predefined libraries - short and really brief described. Java EE is the counterpart to Microsoft's .net. It's used for advanced projects.
regards
Torsten
I never finish anyth...
|
|
|
|
|
java ee refers to the java enterprise edition, it's a platform for web development.
java usually refers to java standard edition,suitable for develope the basic project like swing, gui.
from china
My QQ: 233357374
|
|
|
|
|
I have this code for to create file in directory.
public class Coba {
public static void main(String[] args)throws IOException {
Writer writer = null;
try{
String text = "apa kabar";
File f = new File("d:/azhar.txt");
writer = new BufferedWriter(new FileWriter(f));
writer.write(text);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("file has been created in directori");
}
}
i want to ask ? how to when i run code mentioned, file in directory open automatically..anyone to help me please ??
|
|
|
|
|
I am note sure what exactly your asking, but having a guess;
The file is automatically opened by the FileWriter providing it is not already opened or cannot be created;
This is as per the specification in the java doc; FileWriter[^]
|
|
|
|
|
I mean..file is already create when i run this program,but these file not opened just created in directory. and i wanna when i run this program these file already created and opened automatical also (together).. ??
|
|
|
|
|
please make small sentences and try to explain again what you want to achieve. No one can understand this.
regards
Torsten
I never finish anyth...
|
|
|
|
|
What about this?..
Runtime.getRuntime().exec ("d:/azhar.txt");
This will do for now
|
|
|
|