🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8083

Re: String Conversion!

#8083
From: Owen Green
Date: Tue, 24 Apr 2001 12:17
20 lines
1644 bytes
I would use somehting like

String Xconcept=concept.substring(1);
int x =0;
try{ 
     x = Integer.parseInt(Xconcept); 
}catch (NumberFormatException nfe){         
} 

IIRC,  NumberFormatException is unchecked so you don't *have* to catch it, if you're sure that the string in question will always represent a valid integer. I tend towards pesimiscm in these things, how4ver, and normally make a point of catching it and not worrying overly about the extra overhead which doesn't  matter so much for my purposes. 

This, I would, guess is a matter of taste as much as anything, and some people may not want to catch it (the exception, that is). 

hth 
Owen 


> how can I convert a string to an integer?
> String Xconcept=concept.substring(1);
> Int X = Xconcept ??????????
Technical Details
Message-ID: <3ae56ee2$1_2@dnews>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!f.de.uu.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3ae55f80_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,e974e2e873d092eb
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-04-24 05:53:09 PST
From: "Owen Green" <owen@norobots.unique.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3ae55f80_1@dnews>
Subject: Re: String Conversion!
Date: Tue, 24 Apr 2001 13:17:33 +0100
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 213.86.7.136
Message-ID: <3ae56ee2$1_2@dnews>
X-Trace: dnews 988114658 213.86.7.136 (24 Apr 2001 05:17:38 -0700)
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!f.de.uu.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews