The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Something to work with.

Posted by simul on June 10, 2001 at 10:05 PM

Try putting the value from your substring into a number like this:

int parsedNumber = Integer.paresInt(num.substring(0,2));

use logical and '&&' or logical or '||' in your if statment to match on more than one condition. Like this:

if(parsedNumber == 12 || parsedNumber == 25 || parsedNumber == 35){
//will execute if any of the conditions match.
}

hope this helps.
Simul

> I need to see if the first two digits are 12,25,35 etc. depending on these numbers I need to assign values to variable. How can I achieve this. I have the following code it works fine with one:
> ===========================
> if (!num.equals("")){
> if (num.substring(0,2).equals("25")){
> cata = "A";
> order = num;
> }
> else {
> cata = "B";
> ctr = num;
> }
> }

> ==================================
> if (num.substring(0,2).equals("25")){ here I need to have if the values .equals("12" "25" "35" etc) how can I do this.

> Thanks in advance :)






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us