0
Can any one explain how to read character into an array?
Since learning java a month i don't how read a character array plz explain Without the help of string Another thing is that is nextChar() is available in java as nextInt() Is it available then explain how to use it?? Or explain how tobread character array in java
2 Réponses
+ 4
String s = "string";
char[ ] charArray = s.toCharArray();
+ 2
"is nextChar() is available in java as nextInt()"
~OP.
No there is no nextChar() method for Scanner class. We usually take string input with next() and use it's first charecter using charAt(0)
```
var sc =
new java.util.Scanner(System.in);
char c = sc.next().charAt(0);
```