How to read characters in a string in java -


I'm new to Java, so I'm sorry that this is a clear question.

I am trying to read a string character with the character to create tree nodes. For example, input "HJIOADH" and nodes HJIOADH

I have seen that

  char node = reader .next () charAt (0). I have four nodes = reader.next () I can get the first four hours by CharAt (1); Can I do this with the other Chart J?   

Can I use a circle to get all the characters? As n node = reader.ext ()

 . Charite (i)   

I tried but it does not work.

Scanner Reader = New Scanner (System.in);

How can I do that?

System.out.println ("input your nodes as capital letters without space and end in '/' '); int i = 0; char node = reader.nxt (). Charite (I); While (node! = '/') {

  CreateNode (node); // This is a function to create a tree node i ++; node = reader NXT (). Charite (I);}    

You can only next ( ) Once your reader, unless it is repeated repeatedly in it.

  string nodes = reader.a (Int i = 0; i & lt; nodes. Length (); i ++) {System.out.println (nodes. ((I));}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -