Results 1 to 8 of 8

Thread: String.length?

  1. #1
    rizowski is offline Member
    Join Date
    Nov 2010
    Posts
    37
    Rep Power
    0

    Default String.length?

    Hello, I am currently having some issues with the .length for Strings.

    Class: String
    IDE: Eclipse
    Error:The method length() in the type String is not applicable for the arguments (String)

    I am using Eclipse and i keep getting this error:
    Java Code:
    The method length() in the type String is not applicable for the arguments (String)
    all i have typed in is this:
    Java Code:
    String.[COLOR="Red"]length[/COLOR](hexadecimal);
    From what i can tell is that it should be working from the java api. But idk exactly what i am doing. haha it is very frustrating when you have worked on this for hours.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,299
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by rizowski View Post
    Hello, I am currently having some issues with the .length for Strings.

    Class: String
    IDE: Eclipse
    Error:The method length() in the type String is not applicable for the arguments (String)

    I am using Eclipse and i keep getting this error:
    Java Code:
    The method length() in the type String is not applicable for the arguments (String)
    all i have typed in is this:
    Java Code:
    String.[COLOR="Red"]length[/COLOR](hexadecimal);
    From what i can tell is that it should be working from the java api. But idk exactly what i am doing. haha it is very frustrating when you have worked on this for hours.
    The length() method doesn't take any arguments; also read what the compiler is trying to tell you. That method just returns the number of characters in the String.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    28

    Default

    Per the Java API, does the length method take a parameter?

    edit: dang! scooped by Loretta!
    Last edited by Fubarable; 11-20-2010 at 06:25 PM.

  4. #4
    rizowski is offline Member
    Join Date
    Nov 2010
    Posts
    37
    Rep Power
    0

    Default

    How would you measure a String length then? I was looking for a Method to do so but if it doesn't take anything in, I am not sure what to use?

    Thanks for the help

  5. #5
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    6

    Default

    Assuming hexadecimal is the name of the string you're trying to find the length of, hexadecimal.length() will return its length.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,299
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by rizowski View Post
    How would you measure a String length then? I was looking for a Method to do so but if it doesn't take anything in, I am not sure what to use?

    Thanks for the help
    Suppose I have a String:

    Java Code:
    String s= "foo";
    Its length is found here:

    Java Code:
    System.out.println("length: "+s.length());
    See? No parameters for that method.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,299
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by Fubarable View Post
    edit: dang! scooped by Loretta!
    Hah! Men! They're always so slow.

    kind regards,

    Loretta ;-)
    The only person who got everything done by Friday was Robinson Crusoe.

  8. #8
    rizowski is offline Member
    Join Date
    Nov 2010
    Posts
    37
    Rep Power
    0

    Default

    Oh duh! i should have guessed! ha Well thanks! Even though this seems simple haha

Similar Threads

  1. string length HELP PLZ!!
    By vette427 in forum Eclipse
    Replies: 1
    Last Post: 09-23-2010, 06:12 AM
  2. How can I restrict the length of string in JTextField?
    By vicks.very.cool in forum AWT / Swing
    Replies: 4
    Last Post: 07-29-2010, 05:34 PM
  3. Validating for length of String
    By Bascotie in forum New To Java
    Replies: 1
    Last Post: 10-11-2009, 11:45 AM
  4. Replies: 1
    Last Post: 01-14-2009, 06:19 PM
  5. [SOLVED] String Length issue.
    By ChrisMayhew in forum New To Java
    Replies: 7
    Last Post: 01-11-2009, 04:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •