Vinoth Kumar Kannan

Ranch Hand
+ Follow
since Aug 19, 2009
Vinoth Kumar likes ...
Netbeans IDE Chrome Java
Merit badge: grant badges
For More
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 Vinoth Kumar Kannan

Rahul Sudip Bose wrote:I wonder what will happen if someone passes a string which uses only \ as separator to such a method. So , the person has to be aware of how he should type the strings.

Yes. The programmer must be aware that the argument to the split() method takes in a String that is a valid Regex pattern (similar to the argument you'd use for Pattern.compile())
The API documentation clearly states that the argument must be the 'delimiting regular expression' - String split
13 years ago it! I made a blunder.
Thanks Stephan
Welcome to JavaRanch

In Java, you cannot compare 2 Objects(in this case - Strings) with '>' or '<'.
You can use the compareTo() method of the String class.
13 years ago

Now, each of the 'Lost' objects created have 2 valid references pointing to it.
object1 is being referenced by e1 and e2.e
object2 is being referenced by e2 and e3.e
object3 is being referenced by e3 and e1.e

Here, when you set e3=null, object1 loses one of its references. Since e3 is set to null, e3.e is not valid anymore. This makes object2 lose one of its references.
Now it becomes,
object1 is being referenced by e1 and e2.e
object2 is being referenced by e2
object3 is being referenced by e1.e

After this object2 loses its references completely and is eligible for GC. Also, e2.e is not valid anymore and so, one of object1's references is being stripped off.
object1 is being referenced by e1
object2 is not referenced at all
object3 is being referenced by e1.e

Finally, after this part, the remaining objects(object1 and object3) are also being unreferenced completely and are eligible for GC.
object1 is not referenced at all
object2 is not referenced at all
object3 is not referenced at all

Hope this makes you clear.
Things like this gets easier when you sit down with a pencil and paper, and draw out.

Is there any way using regex,where i can get lines number too where the match is found?

I dont think so..
According to the regex engine, you give it a set of characters(or a String simply) - 'blah blah blah \n blah blah blah \n....'. It'll just help you match your pattern in the input string, but will not keep track of the line number('\n') and it is not designed to do so... but, you can always get the start/end index where your match occurred and do some work around with it to find the line number.
13 years ago
Actually what you're doing is, you're constructing a date object with the information you have in a String and you're then printing the Date object. The date object has a standard formatting and it is how its toString() method has been implemented internally.

But,I want the date in the same format 'dd/MM/YYYY hh:mm:ss' ('15-03-2011 15:27:53')

You can have a date in such customized format only when you convert it into a String. Like what you already did..
13 years ago

Rob Spoor wrote:...because you don't move tempIndex forward....

Oh yeah yeah..tempIndex must be incremented. Actually, I just was trying to give a sample code on spot to get to the concept I was trying to explain..& so it is a non-tested code.
I missed the the second line in the for loop. I must have included..

Thanks for correcting, Rob
13 years ago

John Kwest wrote:
I need to know how to just get everything before the third line break and discard the rest

After parsing the text part of the <description> tag into a string, as Rob mentioned, you can possibly use indexOf("<br/>") 3 times to find the index of the string where the 3rd break is actually happening and use substring() to extract the data...Something like...

Or alternatively, you can use regular expressions to parse off.
13 years ago
I too don't think this is shall be considered at the end, if you have selected some answer - independent of whether you mark a question for review or not.
It'd be really great if you can post a part of your xml here as a sample and state clearly what you need to do on it and mention whatever you have tried so far....,
so that people here can have a look at it and give their ideas on improving your processing.
13 years ago
You can get to understand things far very clearly, when you try them out yourself.

May be I can help you with the concept.
The first line of every constructor must be a call to super() - parametrized or non-parametrized, or this() - parametrized or non-parametrized. If you dont do either of this explicitly, the compiler inserts a simple 'super()' to the first line. It doesn't care whether your super class has a non- parametrized constructor or whether it is public/protected/ just inserts one. So, in that case you're going to get a compile error, when you don't have a non-parametrized constructor in your base class. If you're going to overload you're base class constructor, then take care you have a non-parametrized constructor or make sure your sub class calls explicitly the parametrized constructor in its constructor's first line. If you're not going to touch(overload) the base class's constructor at all then thats very fine, as the compiler shall provide you with a default constructor.
This is the only thing you'll have to watch out for. In your subclass, you might/might not have parametrized/non-parametrized constructors, and that really don't matter much - its ultimately the super class's constructor that is going to be invoked.
13 years ago
java.util.Timer and java.util.TimerTask classes can help you set timers in java. With this, you can schedule a particular part of your code to be executed in specific intervals.
I would consider this better than sleeping & waking inside a loop.
13 years ago
When you invoke getStackTrace() on a Throwable object, it gives back you an array of java.lang.StackTraceElement - each element representing a single line in the stack trace.
You need not parse the stack trace at all, as it is just an aggregation of individual data.
Try exploring the java.lang.StackTraceElement class for more info.
13 years ago

veda kakarla wrote:......but in HashMap.. we should pass key to get value... how this process is going? i m in confusion, will you please clear it?

In a HashMap, essentially all the keys are stored in a Set. So, the same concept as for Set applies here too. When you ask for a value by giving the key, hashCode() and equals() shall be used to identify the bucket in which the key is in. Once the key is located, the value can be retrieved in no time.
13 years ago