java - How do you take inputted characters and output them a certain number of times? -


i have write program takes 2 inputted characters , print them out x times using method. have far, output numbers instead of characters. how can fix it?

int length; char ch1; char ch2;  system.out.print("enter character: "); ch1 = input.nextline().charat(0); //input refers scanner. system.out.print("enter second character: "); ch2 = input.nextline().charat(0); //input refers scanner. system.out.print("enter length of line: "); length = input.nextint(); //input refers how many times characters ar$ draw_line(length, ch1, ch2);  //method starts here.  public static void draw_line(int length, char ch1, char ch2){     (int = 0; < length; ++i){         system.out.print(ch1 + ch2);     } } 

this because adding chars not concatenation. please see question: in java, result of addition of 2 chars int or char?

what want string containing 2 chars, shortest edit is:

system.out.print("" + ch1 + ch2); 

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 -