java - Is there a way on getting Scanner input without having to create an instance of the class? -


let's have code:

scanner scan=new scanner(system.in); char x = 'h', aux; system.out.println("insert single letter"); aux=scan.nextline().charat(0); if (x==aux)system.out.println("match"); 

is there way avoid

scanner scannerobject = new scanner(); 

and work done function tool c's scanf() or fget()? confused this!

you don't have use scanner input in java. scanner high level class parsing input while reading it. can read static inputsteam system.in. want wrap in bufferedreader though since want deal strings more byte arrays.

e.g.

bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string line = br.readline(); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -