Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

sanjay kumaresan

Greenhorn
+ Follow
since Jun 29, 2001
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 sanjay kumaresan

Hi
You have to set the classpath as follows
Goto Dos prompt,
Type the following commands
set classpath=c:\j2sdkee1.x.x\lib\j2ee.jar;
set path=c:\j2sdkee1.x.x\bin;
Now try to compile your application it will compile.
The following steps for j2sdkee.
Definitely it will work. Even any problem you can contact me.

Email: sanjaykumaresan@rediffmail.com

Yahoo messanger id: sanjaykumaresan
Best of luck
M.Sanjay
Hi Madam
It is enough to run the application.
Because you have
1. class file (created from another system there you have java
environment)
2. JVM
3. going to download the jre.

The following are enough to run the application.
M.Sanjay
18 years ago
Gothrough the code. Definitely you will get what is hashtable and how to use it.
/*Hashtable is used to store and retrieve objects*/
import java.util.*;
class htable
{
public static void main(String args[])
{
Hashtable h=new Hashtable(); //Default constructor
int i=0;
String s[]={"Sun","MicroSoft","Bell"}; //object initialize
//storing the object in the hashtable.
h.put(s[0],"java");
h.put(s[1],"c#");
h.put(s[2],"c");

//getting the objects one by one
while(i<h.size())>
{
System.out.println(h.get(s[i]));
i++;
}
h.clear(); //clear the hashtable
} //end of main
}

The while loop condition is
i less than h.size()
If you want more information about hashtable mail me. I will give the details.
Email id: sanjaykumaresan@rediffmail.com
M.Sanjay

[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
18 years ago
Hi Revathi
You got Really good mark.
All the best for your bright future.
M.Sanjay
18 years ago
Hi ameen ahamed
It's really a good question.
Your code I just added the Line numbers(I am explaining through the line number)
1 : class test{
2 : private int i=mym();
3 : private int j=9;
4 : int mym(){
5 : return j;}
6 : public static void main(String args[]){
7 :System.out.println((new test()).i);
8 :}
9 :};

At the run time only the values are going to allocate in the memory. Before that only empty memory is there. When the control enter in the main method i and j are zero (Because of int).
In main method you are making the object and trying to access the value of i in line number 7.
The control is going to the following way.
1) Line number 7
2) Line number 2
3) Line number 4
4) Line number 7
The run time environment is not entered line number 3. Before that you deveate the control to other line.
Try and understand:
Just interchange the lines of 2 & 3 you will get the prober output. Try to print inside the mym also. There also it give zero only.
I think now your problem is clear.

If I am wrong, you can mail me.
My mail id is :sanjaykumaresan@rediffmail.com
Bye
M.Sanjay

I am sure:
The question is 100% correct.
The logic behind in the question is the Thread concept.
When you call the start() method it will call the run() method.
But the control will go to the main method and check whether the main method has any statements or not. If the main method has any statements first it will be execute then only it will enter the run() method.
Now come to our application.
1. It is calling the piggy method
2. concadinating the string in the LOCAL(not in the global) variable.
3. It is trying to call the run() method, but the main method has statement. That's what the control is going back to the main method and print the string of "vandeleur". After that it is entering the run() method and doing the for loop operation and concardinating 0 to 3. But we are not printing the final result.
I think Now your doubt is clear?
Even if you have doubt, I will give you the modified code try to run it and your doubt will be clear.
public class Tux extends Thread{
static String sName = "vandeleur";
public static void main(String argv[]) throws Exception {
Tux t = new Tux();
t.piggy(sName);

sleep(1000); //Added this line

System.out.println(sName);

}
public void piggy(String sName){
sName = sName + " wiggy";
start();
}
public void run(){
System.out.println("Inside the run method");
for(int i=0;i < 4; i++){
sName = sName + " " + i;

}
}
}
o/p is:
vandeleur 0 1 2 3
Reason: I given the print command after sleep command. In this case the control is entering the run method then it is printing the string.
M.Sanjay

Respected Sir/Madam,
According to the book concept,transient variable can never be static.But,if you declare
transient static int a =10;
its getting compiled.I would like to know the internal concept of the above?
thanking you,

M.Sanjay.
18 years ago
Respeted Sir/Madam,
We have a doubt in the following code:-
class Sample
{
public static void main(String args[])
{
int i=10;
i=i++;
System.out.println("The value of i is: " + i);
}
}
When I run the program,it is giving the output as 10.
Why so?If I store the result in another variable,it is taking as 11.What is the difference between both the cases?
Thanking you,
M.Sanjay.

18 years ago