Harish Kashyap

Ranch Hand
+ Follow
since Jun 14, 2000
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 Harish Kashyap

It doesn't necessarily mean that your program has some error. As I do not see any problem with the function you have written.
Working with swings has always been tricky because they bahave differently on different platforms(OS). They inherit the native windowing capabilities from the underlying operating system.
I would suggest you to add some debug prints and firstly figure out whether this function is at all getting invoked in full screen mode?
Secondly, if your window does not gain focus, then the key press events may not get captured by your program.
16 years ago
consider this

if(x){
System.out.print(" x is true, so I am printing");
}else
{
// x is false, I don't print anything
}

this piece of code will do exactly what you said. but this is not a function.

All functions with a return type must return a value of that type.
So, both your functions have to return a boolean value i.e. either true or false.

so if you call your first function as
System.out.println(frighten(1));
it will print:
arrrrgh
true

and same if you do with your second function definition, it will print
a bite
false

the functions do what they are programmed to do and then return the value irrespective of what it is (as long as it confirms to the return type).
16 years ago
Properties properties = new Properties();
try {
properties.load(new FileInputStream("/project/folder1/file.properties"));
} catch (IOException e) {
}

you must use the absolute path or the relative path of the properties file.
remember, if you are executing p1.p2.A.class then your class could be in c:\p1\p2 folder, but you will be executing it from c:\ so the path of the properties file should be either absolute path or relative path to c:\
16 years ago
Your paint method is being invoked recursively
I would like to correct myself here...

An object is added in HashMap if

1. hashCode doesn't match
2. hashCode matches, but .equals() or || operator return false
18 years ago
That is actually true....
If 2 different objects return same hashcode, only first object will be added to the HashMap.

If you see the src of HashMap

18 years ago
When you add an element to HashSet/HashMap,
1) first the hashcode of object are matched against that of all other elements
2) then the object are matched with either == or .equals

And its added only when the hashcode is not same "and" == or.equals return false

So when you uncomment the hashCode method, only 1 element is added to the HashSet.

Moreover, as per definition of 'hashCode' method

If two objects are equal according to the equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.

So, for correct operations, its your responsibility to override the 'hashCode' method if you are overriding the 'equals' method.
18 years ago
I have never worked it out, but in my openion

a) threading (in terms of handling and performance) may get affected
b) native method calls may get affected
c) networking related stuff may get affected
d)
18 years ago
I don't think we can achieve IPC using Pipes and shared memory in java.
Because you don't have any control over the memory management in java.

moreover unlike C++, we have 2-level referencing in java, so even if you somehow find a memory address to write the data, it won't be actual memory address where the data will be stored.

You can achieve through other means like sockets
18 years ago
use javascript and dhtml to achieve this.
try exploring the concept of innerHtml
if it appears like this in your code then the return statement must have a terminating semi-colon and must be enclosed within curly braces.
i.e.
//Instance Variables
public double enterdollars()
{ return enterdollars; }
18 years ago
Can you be a bit more elaborate when you say "run plain java classes in a server instead of a JVM"

can you be specific on "server" here. Because a server is just an application that responds to incoming requests and thus serving the clients. That server application can be a java class.

To run a java class, you need 'java' interpretter that needs jvm to execute.

even your server might be running under a jvm.
18 years ago
Can you justify your statement....

what about int, after all a reference is an int
18 years ago
Hi Rashmi, I am working in Delhi, India, but am not able to get a job good enough for my expertise.

Hi Peter, I agree with you that knowing another knowledge is always good, but how can you keep yourself rated 9/10 in all the languages you know. To get that level of expertise with another language will require another 3-4 yrs. of your career. And what if after that you are required to learn a third language.
18 years ago
its simple concept of local vs. global scope of variables in this example.

but of course, in line 1 and 2, there is an error...

System.out.println("myBar.barNum in changeIt is " + barNum);//1
System.out.println("myBar.barNum in changeIt is now " + barNum);//2

barNum can't be accessed as barNum, it has to be myBar.barNum
So along with these 2 statements, if you print this.myBar.barNum, your confusion will go off