How do I treat applet parameters as numbers instead of strings, since getParameter() returns a String?

John Zukowski

Depending upon which type of number you wish to treat the parameter as, you would need to call the appropriate conversion routine of the corresponding wrapper class. For instance, to treat a String parameter as an int you would call the parseInt() method of Integer like:

String intString = getParameter("COUNT");
int intValue = Integer.parseInt(intString);

You'll need to catch the NumberFormatException to deal with invalid parameters.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact