This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Problem using StringTokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem using StringTokenizer" Watch "Problem using StringTokenizer" New topic

Problem using StringTokenizer

Ankur Premi

Joined: Aug 07, 2010
Posts: 17
I am trying to use StringTokenizer for saving the value of val (See code below) in different variables.

I have written this code. But this code is returning null values. It's not saving the value of val corresponding to the key.

Please help me.
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

I suppose, it wont even enter the three if statements. How did you decide it gives null values?
Use equals() to compare the contents of 2 strings.'==' is used to check reference equality.

Ankur Premi

Joined: Aug 07, 2010
Posts: 17
thank you vinoth. it worked
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43970
Ankur Premi wrote:I am trying to use StringTokenizer . . .
Why? It is a legacy class.
I agree. Here's the link:
subject: Problem using StringTokenizer
It's not a secret anymore!