CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2013

    [RESOLVED] Using length() method.

    I am just starting to learn java, I am playing with using strings. I am trying to get a code to select a random word and print it.

    public class test2 {
        public static void main(String[] args) {
        String[] wordListOne={"Dave","Nick","Paul","Mark","John","Bill","Gil"};
        int length1 = wordListOne.length();
        int rand1 = (int) (Math.random() * length1);
        String finalPhrase = wordListOne[rand1];
    length() is not working and I am getting the error, "can not find symbol - method length()"

  2. #2
    Join Date
    Jan 2013

    Re: Using length() method.

    Fixed it myself. Got rid of round brackets and that was the key.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.