java - Looping in vertical position -


i beginner in java , seek help.

write method called vertical accepts string parameter , prints each letter of string on separate lines. example, call of vertical("hey now") should produce following output:

h e y  n o w 

this have done.

public void vertical(string x){     char onebyone='x';         for(int i=0;i<=x.length()-1;i++){             onebyone=x.charat(i);         }         system.out.print(onebyone); } 

it gives me w when call it. confused.i create char container , call out position 0.and loop through it.shouldn't position 0 starts h.instead of giving me w?

also,should use public void vertical(string x){ or public static void vertical(string x){?they give me same output.i go research on static , tell me static means single.what means?

public void vertical(string x){     int count = x.length();     for(int i=0;i<count;i++){        system.out.println(x.charat(i));     }       } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -