Java Scanner Using and additions

To day is the big day to my friend it's birthday for him, I wish he can be good.
Ok! Today I want to talk the Scanner and File Reader event.
First We need to know on below:
1. Scanner Numbering
2. Scanner String reader
3. Scanner if and else
Ok , let we know about String, I think Everyone saw the String [] args in the every i opened java program because it was meaning you can open your terminal and text :
User-PC@~/: java -jar [YourProject] arguments
When the user type arguments and args String will show it and this thing can use on if or else, but what is if and else in java, simplify the if just say if your event is work to do for, and else just your event doesn't working to do.
like this one :
if(args.equals("valid")){

System.out.println("TRUE");
}else{
break;
}
this just like the sentence let me explain it when user type in terminal like:
 User-PC@~/: java -jar [YourProject] valid
the project will execute like this

TRUE
PS: All String equals can use sort the upper or lower symbal ignore all use String.equalsIgnoreCases([Stringname])
and what we need to know it because the Scanner like arguments but it is ask arguments in progress like this one :
System.out.println("Valid or void");
Scanner s = new Scanner(System.in);
String input1 = s.next();
if(input1.equals("valid")){
System.out.println("true");
}else{
System.out.println("false");
}
that you text valid it will text true, then you text the other one it will text false that is easy to use, how about two or more cases reading execute you can use elseif, elseif is meaning you don't like to use this but I need another choices this is an example:
if(input1.equals("true")){
System.out.println("true");
}else if(input1.equals("valid")){
System.out.println("true");
}
And this command will make your computer say true when you text true or valid, then it will text,or you text another thing like false it will never worked!
Next We need to know how to using a numbering input
example input the number and showing this number
int s1 = input.nextInt(System.in);
int x = 10;
for(s1<s1+x;s1++){
System.out.println(s1);
}
if you text 10 it will show 10 and 11 that you can know the counter how to build and you change your number x and hope you enjoy it see you next time dude!

留言

這個網誌中的熱門文章

Spanish subject categories