Need help wiith length() method

Discussion in 'Software' started by slashgonewylde, Jan 7, 2010.

  1. slashgonewylde

    slashgonewylde Private E-2

    Write a program that asks the user to enter a word. The program will then repeat word for as many times as it has characters:

    Enter a word:
    Hello

    Hello
    Hello
    Hello
    Hello
    Hello

    To do this you will need to use the length() method that counts the number of characters in a string:

    String inputString;
    int times;

    . . . .

    times = inputString.length()

    //The above is the question and when run its tells me that the java.lang.String cannot be applied to (int)

    and it refers to the line times = inputString.length(word);
     
  2. XTAL256

    XTAL256 Private First Class

    What is "times = inputString.length(word);" supposed to do? I am not aware of any length method that takes a parameter. What type is the "word" variable?
     
  3. SWario

    SWario Sergeant


MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds