Step 4: Make it say something

ok, so you already have the code

class Pythagorean {
public static void main(String[] args){

now make it say
class Pythagorean {
public static void main(String[] args){

String greeting = "Hello. Welcome to the Pythagorean Theorem Application. Today we will be computing the Pythagorean Theorem for you.";

String prompt = "Please enter a number for the first leg of a right triangle, followed by pressing ENTER or RETURN, followed by the remaining leg. Then hit ENTER or RETURN one more time.";


let's break it down!
A string is any line of text
this is a variable: it can vary
greeting and prompt are the names of the strings
so in the line
String greeting;
you are creating a string called greeting
note the semicolon
all statements in java should end in a semicolon or else ERROR
you use = to assign the value to the variable
this can be done like this:

String greeting = "Hello. Welcome to the Pythagorean Theorem Application. Today we will be computing the Pythagorean Theorem for you.";

or like this:
String greeting;
greeting = "Hello. Welcome to the Pythagorean Theorem Application. Today we will be computing the Pythagorean Theorem for you.";

in this case you are declaring and assigning the value of the variable in two steps
in the former case you are doing in one
both work equally well

all the text that you want in the variable must be put it "quotes"

the line System.out.println call for the SYSTEM OUTPUT to PRINT the LINE of the variable
if you called System.out.println("HI");
the terminal would print
but note the quotes
the quotes say that what's inside is text, not the name of a variable
if you called System.out.println(HI);
the terminal would respond with an error because it thinks you wanted to print the value of the variable HI
memorize this command: you'll use it all the time

Hey, this is a great instructable and is very informative. Just one thing is missing... pictures! It really helps a lot when trying to follow directions so you should consider taking some photographs. Once you do that and leave me a message when you have so that we can publish your work. Thanks! Thanks for the cool instructable and we hope to publish this soon!
<p>he is corrct!!!!!!!!!</p>
sorry about that, I should've thought of that ahead of time is this any better? o, should I hit publish again?
nevermind, it apparently worked
hey this was a great tutorial from u- and i think u did a great job i'm no-beginner in java but i love great intros like this- love the analogy of a class as a recipe (priceless). the bottomline is most manuals bore the heck out of someone but simple flows like yours makes it engaging and relatable. Good job!
Best tutorial ever!!!!!!
i gots a problem already my command says 'javac' is not recognized as an internal or external command.....help
that means you don't actually have java installed<br/>it's a simple mistake that I've made countless times on all the computers I've worked on<br/><a rel="nofollow" href="https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u14-javafx-1.2-oth-JPR@CDS-CDS_Developer">https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u14-javafx-1.2-oth-JPR@CDS-CDS_Developer</a><br/>follow the instructions from this link and you'll be all set<br/>
i am trying to get started in java and u have inspired me with that amaaaazing intro paragraph i actually laughed time to read...
Beginners:<br/><br/>Try the BlueJ Editor for coding: <a rel="nofollow" href="http://www.bluej.org/">http://www.bluej.org/</a><br/>It shows classes as blocks, to emphasize the &quot;Object Oriented Programming&quot;, and it's very easy to use.<br/><br/>And bookmark these URLs:<br/><a rel="nofollow" href="http://java.sun.com/javase/6/docs/api/">http://java.sun.com/javase/6/docs/api/</a><br/><a rel="nofollow" href="http://java.sun.com/docs/books/tutorial/">http://java.sun.com/docs/books/tutorial/</a><br/>The first one has a list of all the classes, interfaces, etc that you might need.<br/>The second one has many useful Java tutorials.<br/>
I program in C, and am learning Java. The only thing Sun Micro-Systems didn't include was short names for the library functions.
One thing, you shouldn't write programs in "pretty much any word processor". Programs should be written in an IDE or text editor. Text editors (like notepad, but NOT like wordpad, word, etc...) produce plain text files. Word processors like m$ word and OpenOffice writer produce files full of formatting commands that no compiler or interpreter (as far as I know) will be able to understand.
you can write them in pretty much any word processor though when you hit "Save As" there's almost ALWAYS a list that allows you to choose your extension this is true for BOTH Wordpad and Word and I've used both to program before
OK in the command line i typed in C:\Java\javac Pythagorean.java and it just tells me that 'javac' isn't an external or internal command. i don't know how to do it i tried it the way you typed on the 'for windows' and it doesn't work
it works like this C:/directory/subdirectory>javac whatever.java make sure you know EXACTLY where it's saved AND use the little > thing
if it still doesn't work, I should've told you to make sure java is installed
whatever thanks anyways for the additional help your instrucatble is great keep at it
don't give up dude! www.java.sun.com this has everything you need download java 6 and I'll help you from there
o great and what word processer should i use i tried notepad the rectangle didnt work there? thnx sorry i posted twice ihad a prob w/ the comp
I'm guessing you fixed it, looking at your next post
uh how do you do the rectangle thingy on line 1?
it's the keys you use to make { and } without the shift
can u please tell me how to do the rectangle shape thing class Pythagorean{public static void main(string? args){ im a noob so any additional help would be great
it's not a rectangle thing it's two keys it's the ones you use to make { and } without the shift
I don't know much about Java, but this Instructables looks great for beginners like me or other people...well explained!!! Maybe change the front picture with a Java symbol and add more images to attract visitors and maybe get featured... All in all a great Instructables! rate:*****
FIRST! no, just kidding but seriously, if you have questions or anything... I love helping people it makes you feel warm and fuzzy!

About This Instructable




Bio: I'm bored, I got time on my hands, and I love to make things. My motto has always been, "If you want something done ... More »
More by The_Vinninator:How to write useful programs in JAVA 
Add instructable to: