Piyush Porwal

Ranch Hand
+ Follow
since Apr 09, 2008
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 Piyush Porwal

I like the ideas thrown in this article if that helps you. It basically says that it may really doesn't matter, what class you use, in terms of performance.

http://www.codinghorror.com/blog/archives/001218.html
%1 in the 'format' argument means replace %1 with first argument.
coz of data type. A,B,C are of type int whereas, expected values are of type MEnum
Depending on the type of the expression in the switch statement (in this case type of me=MEnum) it will expect the same type in the case statement. More ever they should be constants. Which means A,B,C in case statements are of type MEnum and not variables of type int, defined above the switch.
Thus, given that the value of 'me' is 'A', 'switch(me)' will match 'case A' and hence will print the answer you mentioned 'Only A Only B Only C' (as there is no break statement in between).
Please explain in more detail what are you trying to achieve and if possible some sample code.
13 years ago
I am not sure if I am getting your question correctly. In case you are asking


In File 1:
PPTY1=PPTY2
In File 2:
PPTY2=VALUE1


and you want to assign VALUE1 to PPTY1, then you have to use another module/script to do this for you. So for example you can mark your replace-able properties like this:


In File 1:
PPTY1=${PPTY2}
In File 2:
PPTY2=VALUE1


And your script will look for such occurrences to replace. This should be done before you start your actual business related processing.
13 years ago
I am talking at the SQL level like "How to find ...." in DB2 type of questions. Any specific site/forum you know, apart from IBM website.
For example, "what is the equivalent of Sybase's sp_spacereport in DB2".
13 years ago
just wondering if there are ranch type well managed forums for Db2/390 or db2/udb to discuss any doubts?
or at least where participation is good...
13 years ago
Thanks much for your effort. Didn't know java does so much for you!!
Although extending anonymous classes this way seems natural and common, but not sure when should this way of implicit instance variable should be used. Let me read bit more on this and if I found any good link will post here.
13 years ago
wonderful, looked deeper than my normal understanding of anonymous classes and found the answer for point 1 and 2. Thanks.
Some info is discussed here: http://forums-beta.sun.com/thread.jspa?messageID=715086

I am yet to find answer for point 3, any further pointers?
13 years ago

Is it a right thing to do or better i should create a new Comparator ? My old comparator code is for Double value's and my new code added
is for String.



Generally speaking, you are free to alter your comparison approach any time. So this should not be an issue. But you may still want to check the client of this comparator (specially if they have access to this code or if the name of the class says something) to confirm that they are not making any assumption based on your current implementation.
13 years ago


This code is from Item 16 - Prefer interfaces to abstract classes (Effective Java Ed#1) - Page# 86

I am kind of puzzled by looking at this code. I have several doubts and by looking at the sun docs, I could answer few of them. Please help for the rest:

1. Is the code in the return statement over ridding the get/set/size methods - YES (got the answer after I checked the API docs and it says that these methods must be overridden). But I do not see extends anywhere?
2. AbstractList is an abstract class as per the API docs, how can a new be done on it without extending? (Line 1)
3. When and where the values from int[] a, gets assigned to Integer List? Within the object of AbstractList, where are these values kept? (May be I am posting a non-sense question, as not sure what is the behavior)

Probably after the explanation, I would also get why this implementation is termed as Adapter patter in the para below the code.
13 years ago
From what I have read in the books, a try..catch block should consists of minimal code which can throw an exception. So if return is not expected to throw any exception, it should be outside of the try block. If you are doing something funky in the return like as simple as

then move it out only when you do not expect Dog constructor to throw an exception or if you do not want to catch it.
13 years ago
Think recursively
Just consider one level at a time. Display contents of a node and then (recursively) for all its children (sub-dir) call this same method.
13 years ago
Virtual machine (or in fact your application) MAY run fast, it is not the case always. Most of the time it gives performance benefits because as the variable is final, it can be used for compile time optimizations of the code. For example if you are doing

range = MAX_VALUE - MIN_VALUE


where MAX_VALUE and MIN_VALUE are final variables, then this can be calculated at compile time itself and hence gives a minor performance gain. It can scale further, it such things are repeatedly, say in a loop.
13 years ago