hi all
i read the scanner class documentation from sun's website and i thought i would have some fun trying to write a program that stores a line from the user to var input and then parses it on white space then depending on what the new string is i will do somthing. i think there is an easier way than what i am trying but i am just trying to get these concepts down before i move on to my next step. i am getting an incompatiable types error in my loop condition
i am not even sure if what my while condition does is legal, i am basicialy saying to keep going until there is no more substrings in the string.
if you could point me toward a different manual or offer some of your own advice i would be grateful
eric
i read the scanner class documentation from sun's website and i thought i would have some fun trying to write a program that stores a line from the user to var input and then parses it on white space then depending on what the new string is i will do somthing. i think there is an easier way than what i am trying but i am just trying to get these concepts down before i move on to my next step. i am getting an incompatiable types error in my loop condition
Code:
import java.util.*;
public class asg3 {
static Scanner console = new Scanner(System.in);
public static void main(String[] args) {
String[] arrnums = new String[20];
String input = " ";
Scanner parse = new Scanner(input).useDelimiter("\\s*");
int i = 0;
Random ran = new Random();
System.out.print("please enter a number, /n enter 'r' to insert a random number \n you can send a max int using the following syntax 'r(max int) \n enter 'sub' to submit data, enter a q to end program \n");
input = console.nextLine();
System.out.print(input);
while(arrnums[i] = parse.next())
{
System.out.println(i);
//and some other stuff
i++;
}
}
}
if you could point me toward a different manual or offer some of your own advice i would be grateful
eric
Comment