java scanner string format code example Example: initialize scanner java Scanner sc=new Scanner(System. in);