prateek chaudhari

Greenhorn
+ Follow
since Oct 14, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by prateek chaudhari

I Just want to ask I am not sure, can "Java Reflection" help him? :roll:
16 years ago
I think there is no need of lists if the size of the array is limited to mazimum 10 elements, as shown in the question.

Its is very easy problem, the only thing it may require you to have a simple knowledge of "Ragged Arrays" which will help you.
16 years ago
For displaying the object state specific information, you need to override the toString() method.
In your case your Cup class can have a method public String toString(){ return <some String that shows objects state>;}

The output you are getting is because when you call System.out on any object the method calls the Objects toString() method, as the Object class default behavior shows the Hashcode you are getting that output.

so just override the toString() method and you will get the output the way you want it.
16 years ago
Actually Campbell explained it very well, but I'd like to elaborate more on that.
Yes, its perfectly right for an interface to extends more that one interface by doing so It can provide facility to combine application specific functionality available in different interface to be clubbed together. At the same time this new interface can provide some overloaded version of the overridden method, so the implementing class can use them polymorphically.
16 years ago
Gregg Did it Very Corrrect

You need to have a ActionListener Class (A class which implements an ActionListener) which will listen to the Events, Here Gregg has done that with annonymous class.

This class will have a single method named actionPerformed(ActionEvent e) which will be invoked as and when the button pressed event is fired. You can add your functionality here.

After which you need to register that with the Action Generator here in this cas A JButton by using addActionListener() method.

That's it and you are there....
16 years ago
Its all about references comparison.

If I am not wrong ..You have crated 4 Integer objects, when you compare object references using == then the values inside reference (which is something how to get object values from heap) is checked while when you use equals() method which is inherited by every class in Java you compare the values pointed by the reference variables.

So its not necessary that always your first condition evaluates to true.

but your second condition will always evaluate to true,(Till values are same.) cause equals() is overridden in Integer class.
[ August 09, 2007: Message edited by: prateek chaudhari ]
16 years ago
Hello All,

Actually I was going through JavaDocs 1.5 for java.lang.Class description and found this statement in very first paragraph.

"The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects."

any one of you, if possible please explain me the gist of this statement.

Thanks in Anticipation
Pratik
16 years ago
Hi

You should have somePlaceHolder for adding element into the html through javascript so that when you do the page doesnot get refresh like div or span

<div id="div1"></div>

add the onClick event on your so called add button which will then call some javascript method


In this javaScript method now you can add

function showSomeThing(){
var divName =document.getElementById("div1");
divName.innerHTML="<input type='file' name='FileName'/>";
}

and on your server side code you can access this fileName using someName as parameter name, sent from the client.
[ June 13, 2007: Message edited by: prateek chaudhari ]
Actually In java The Filename should match with the Public class inside that filename, Not with the class which has main method.

This is a requirement of the Java reference compiler released by Sun.

And this is the reason what I found on SDN network, which says

it's in the JLS. Section 7.6:
"When packages are stored in a file system (�7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) if either of the following is true:

* The type is referred to by code in other compilation units of the package in which the type is declared.
* The type is declared public (and therefore is potentially accessible from code in other packages).

This restriction implies that there must be at most one such type per compilation unit. This restriction makes it easy for a compiler for the Java programming language or an implementation of the Java virtual machine to find a named class within a package; for example, the source code for a public type wet.sprocket.Toad would be found in a file Toad.java in the directory wet/sprocket, and the corresponding object code would be found in the file Toad.class in the same directory."
[ June 11, 2007: Message edited by: prateek chaudhari ]
16 years ago
Yes, the Link given is sufficient for you to find all the information that you need to know about the Properties of the Object, but say suppose if in near future you want to know something more about the Classes in JDK, my advice will be to first go through the JDK doc which is very useful to gain understanding of the sturucture.

You can download latest version of JAVA doc from sun site

sunhttp://java.sun.com/j2se/1.4.2/download.html
16 years ago
Yes! In windows enviornment you can copy the .jar file location directly to the CLASSPATH system variable so that you dont need to include them again and again.

YOu need to

goto control panel->system->select advanced Tab under this you will find 2 buttons at bottom side of the dialog click on enviornment variables->select the CLASSPATH varible from system varibles list if it is not there then create one and insert the location of the .jar file, now its done!
16 years ago