venu surampudi

+ Follow
since Jan 03, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by venu surampudi

I admire people who accept failure. good luck for the 2nd attempt, i think you will nail it.
12 years ago
Thanks ralph, i think the whole decompile to understand what is compiled is a very good idea.

If enumerations can be declared outside of a class, then what class do they belong to? To elaborate, i have source file which has the class test1 and outside of the class i have an enumeration declaration. To refer to this enumeration from another class i am having to do a reference like this test1.Enum e = test.Enum.Val1. Should the declaration be tied to the class even if it is outside the class. Is it tied to the source file name? I guess i am spiralling.

appreciate all the help
Here are the rules in descending order of priority for the first call to doX

1. Find an exact match , in our case it first looks for method that has a signature doX(short, short) which it cant find

2. Try to see if it can box the variable and find a match in this case it now looks for doX ( Short, Short ) which it cant find again

3. The next step is to look for a widened version meaning it is looking for something like doX( <Something wider than short>, <Something wider than short > which it does find in

doX(Number,Number) and hence it prints 4.

Since a literal 7 is by default an iteger, here is the priority list of second call

1. Find an exact match , in our case it first looks for method that has a signature doX(int, int) which it cant find

2. Try to see if it can box the variable and find a match in this case it now looks for doX ( Integer, Integer ) which exists and hence

is called to print 3.

Rule of thumb is widen, box, var-args.
Here is the behaviour i noticed.

Case 1
If a variable is declared as an instance variable, and not assigned a value, it will be assigned a default value and CANNOT be modified any where in the code, the variable can however be assigned a value in the declaration statement.

final int x; // will be set to 0 and is final and cannot be modified

fianl int x = 5; // will be set to 5 and cannot be modified.

however just declaring x as final, not initializing it and trying to intitialize its value in a method will cause an error.

case 2:

Now if the variable is declared as final inside of a method, and not initialized, you get one and only shot to assign it.

I think case 1 is compile time constant and case 2 is not.

Let me know if i am lying.
Interesting but i could not get it to run. I get the following exception possible loss of precision

and i also think this is kind of understantable as we are trying to stuff a 32 bit thing ( for lack of vocabulary ) into a 16 bit thing

am is missing something? clearly i am

In the new for construct assuming that a is an integer array

for (final int v: a){

why does java allow us to declare the iteration variable to be final and not complain? doesent it (v) change after every iteration?

Never heard of wicket. but we can fill a library with things i dont know. I will explore.
Thanks you guys, i get the point now.
Here is what i have done.

In the superclass

public int getNumber (Number i){

System.out.println("super class version of getNumber");

Integer k = (Integer)i;

return k;

In the subclass

public int getNumber (Integer i){

System.out.println("subclass version of getNumber");
return 1;

In the main method

superclass mn = new Main();


I get

super class version of getNumber

which means it has not been overridden. SO is the following a valid statement?

"A method can only be considered overridden if the signatures match exactly, an event in which the the signatures pass an is a relationship with the parents method parameters, it is still considered an overload and not an override"

Here is another question from me. If say i have a superclass method that looks like this

public <return_class> meth1 ( <signature_class> )

and the subclass has a method

public <return_class> meth1 ( <sub_class_of_signature_class> )

Am i overloading or am i overriding.


I have a good degree of confusion when it comes to differentiating between the greedy and possesive quantifiers. Here is the code i have been playing with

Pattern p = Pattern.compile("<html>.*+</html>");
Matcher m = p.matcher("<html>ab34</html>asdsdf<html>sfdsfds</html>");
while ( m.find()){
System.out.println("group is ";

ok i understand that if i change the pattern to ("<html>.*?</html>")i get two groups as the wording associated with search is "START LOOKING FROM THE BEGINNNG OF THE STRING AND FIND THE GROUP OF CHARACTERS THAT MATCH THE PATTERN, CONSUME IT, AND MOVE ON TO SEARCH FOR MORE", if i change the pattern to ("<html>.*</html>") it is screaming the logic "START BY LOOKING AT THE WHOLE STRING, IF YOU CANT FIND A MATCH, IGNORE THE LAST CHARACTER, TRY A MATCH AGAIN, IF NOT KEEP DOING IT TILL YOU FIND THE LARGEST PORTION OF THE STRING THAT MATCHES ( OR NOT) ", now coming to the part i dont understand, ("<html>.*+</html>"), i dont understand why there is not a match given that the string as a whole matches the criteria.

Can any one please try, and sorry for the verbose topic desc, i will try to shorten it once iam comfortable with regexes

[ May 12, 2008: Message edited by: venu surampudi ]

I think the answer to the question is "nothing would be printed". In the firt if condition i.e

if((bl & b2) | (b2 & b3) & b3)

the result of b1&b2 is false as one of them is false ( Notice the unboxing that happens b1 is Boolean b2 is boolean) HOWEVER the jvm will still evaluate the rest of the expression as it is NOT a short circuit expression ( if it were || operation the evaluation of the if would end after the first piece ) any way the result is alpha wont be printed.

Coming to the second if condition

if((bl = false) | (b1 & b3) | (bl | b2))

The trick here is to notice that b1 is assigned a false value,in the next part of the expression (b1 & b3), human nature is to look at the declaration section and think they are both true where as in reality you are setting it to false in the first part of the expression ((bl = false) which means part 2 ( b1 & b3 ) and part 3 ( b1 | b2 ) are both false.


good luck

Nice explaination. That indeed would have been way too many methods.

12 years ago
This isnt as much of a question as is to comprehend the thinking behind the Calendar class. Can any one please thrown some light on why adding months ( say 5 )to a date a date should be as convoluted as

Calendar c = Calendar.getInstance();

instead of something like

Calendar c = Calendar.getInstance();

Why the extra step of specifying a static constant that represents a month?

Thanks in advance
12 years ago