Results 1 to 4 of 4

Thread: Help!

  1. #1
    duffman349 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Help!

    im really new to java, just started last night. and today i tried righting a simple little class file that randomly chooses a statement out of a 3 lists of words. anyone here who began java with the "head first java, a brain friendly guide. edition 2" by kathy sierra and bert bates may know what im talking about. well i wrote it following the directions from the book and when i tried to compile it in javac i got 36 errors, all of which i have no idea what they are and what i did wrong. here is the code:

    Java Code:
    public class PhraseOMatic {
      Public static void main (string[] args) {
    
       String[] wordListOne = {"24/7", "multi-Tier". "30,000 foot", "B-to-B", "win-win", "front-
    end", "web-based", "pervasive", "Smart", "six-sigma", "critical-path", "dynamic"};
    
       String[] wordListTwo = {"empowered", "sticky",
    "value-added", "oriented", "centric", "distributed",
    "clustered", "branded", "outside-the-box", "positioned",
    "networked", "focused", "leveraged", "aligned",
    "targeted", "shared", "cooperative", "accelerated"};
    
       String[] wordListThree = {"process", "tipping-
    point", "solution", "architecture", "core competency",
    "strategy", "mindshare", "portal", "space", "vision",
    "paradigm", "mission"};
    
       int oneLength = wordListOne.length;
       int twoLength = wordListTwo.length;
       int threeLength = wordListThree.length;
    
       int rand1 = (int) (Math.random() * oneLength);
       int rand2 = (int) (Math.random() * twoLength);
       int rand3 = (int) (Math.random() * threeLenth);
    
       String phrase = wordListOne[rand1] + " " +
    wordListTwo[rand2] + " " + wordListThree [rand3];
    
       String.out.println("what we need is a " + phrase);
       }
    }
    can anyone possibly tell me what the errors are and where they are and what i did wrong on my part, and possibly copy and paste it into notepad and try to compile it yourself? you may need to do that to try to find where the errors lie anyways. thanks im just a newb and this is frustrating me to no end, im about to give up again.
    Last edited by pbrockway2; 01-13-2012 at 04:18 AM. Reason: code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help!

    Hello and welcome to the forum. A few house-keeping suggestions first:

    I will add [code][/code] tags around your code so that it will retain its formatting and thus be readable.
    You'll want to post any error messages if you get them so we don't have to guess.

    Though I'll guess that one problem you're having is not taking care with your capitalization and spelling. For instance Public is not the same as public. The compiler is *very* persnickety, and so to code successfully, you will have to be too.

    You'll want to read the forum FAQ's for more information.

    edit: pbrockway2 beat me to the code tags!

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,573
    Rep Power
    12

    Default Re: Help!

    There's only one way to address the compiler's messages, and that's one at a time! Don't think of them like a cop pulling you over for speeding or doing something else wrong. They are the compiler's way of telling the programmer about things that need to be done.

    Most people here will expect *you* to post the messages if you can't understand them. That's not just because we're lazy (although I suspect we are), but also because it is important that we can see exactly what you see.

    -----

    One thing does strike my eye though, and that's how you have things capitalised. Class names start with a capital letter like String to make them look different to variables and methods. Keywords all start with lowercase letters, like public.

  4. #4
    duffman349 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: Help!

    got it, turns out one accidentally period after a word in list one was causing 25 of the problems. its a learning process i suppose.

Posting Permissions

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