Welcome to Gaia! ::


does any one out there know syntax for parsing a string to int format in java, i can't remember it for the life of me. also if anyone knows the syntax behind buffered stream so that i can input strings it would be greatly appreciated
hmmmmm, parsing a string for an integer.....

I believe it's something like "1".parseInt(); or "1".parseInteger();
something like

int hi = "variable".parseInt();

i think that is it... i'll give it a shot

Thanks a bunch
Wait, that's wrong

Here's a small program i just wrote. it should explain your solution.

public class parseint
{
public static void main(String args[])
{
int i = (int)Integer.parseInt("1" wink ;
System.out.println(i);
}
}


It returns "1" when you run it.
Mirukuko
Wait, that's wrong

Here's a small program i just wrote. it should explain your solution.

public class parseint
{
public static void main(String args[])
{
int i = (int)Integer.parseInt("1" wink ;
System.out.println(i);
}
}


It returns "1" when you run it.


i just figured it out thanks a bunch...
this is what i wanted it to do
String bob = "34";
int hi = Integer.parseInt(bob);
System.out.println(hi);

by the way do you know anything about manual input of numbers? as in GUI or in buffered stream reading?
what i was doing was using an array and insertion sort... as the user inputs a number it comes in the form of a string so i convert it to an int and then sort it using my algorithm... i need to do the conversion because comparing integers is easier than strings
I've only used IO streams, specifically the cs1.Keyboard class. It can be found from google fairly easily. Just pop Keyboard.class in a folder named "cs1" (case sensitive), and type in "import cs1.Keyboard;" at the top of any program (before the public class.... stuff). A couple of methods in it are readInt(), readString(), readDouble(), and there's a couple others. Just use something like
int ANumber = Keyboard.readInt();
Mirukuko
I've only used IO streams, specifically the cs1.Keyboard class. It can be found from google fairly easily. Just pop Keyboard.class in a folder named "cs1" (case sensitive), and type in "import cs1.Keyboard;" at the top of any program (before the public class.... stuff). A couple of methods in it are readInt(), readString(), readDouble(), and there's a couple others. Just use something like
int ANumber = Keyboard.readInt();



thanks a bunch
Did you find the class? Did it work?

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum