Results 1 to 4 of 4
Thread: Help!
- 01-13-2012, 03:15 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
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:
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.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); } }Last edited by pbrockway2; 01-13-2012 at 03:18 AM. Reason: code tags added
-
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!
- 01-13-2012, 03:28 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
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.
- 01-13-2012, 04:22 AM #4
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks