.:Welcome to our Java tutorials:.

Visit our Web design support Forum

Going into full geek mode for this one

by April Griffin

Nov 4, 2002

Lesson 4 part 2

  • Printing to Standard Output
  • Variables

 

I want you to read over this information. if it seems a little confusing just relax we are just getting you used to the language and even if it doesn't REALLY mean much to you right now it will when we start putting it to use more. What we are setting up for here is what I call (in the words of Laura Croft) an "ahaa" moment so really I want you to scan this over a time two don't worry I wont be quizzing you yet but do read it. You are learning another language and that takes time and effort before you become literate in it so put the effort in and stick with me here.

To print to standard output you type  

System.out.println(string); an example of this would be

  System.out.println("Your Looking Good Today!"); 

Variables: To lay the base down in programming languages Variables are your starting blocks acting as a place in memory to store a value . There  are basically 3 kind of variables local, field and class. You will want to consider the following characteristics of the variable, Data Type,  Scope,  Lifetime , Initial Value, Names, and Declaration. You can name your Variable almost anything, except for after java keywords. if we name our variable "lesson" as in lesson = 4; the script will translate it into 4. if you type  System.out.println(lesson); it will show as 4 in the Java Console. Refering back to when you built your application again you have already used this 

/**
 * The LamersSuckApp class implements an application that
 * displays "Lamers Suck!" to the standard output.
 */
public class LamersSuck {
    public static void main(String[] args) {
        // Display "Lamers Suck!"
        System.out.println("Lamers Suck!");
    }
}

If your going to use a variable you will need to declare its type. The different types of data the variable holds some primitive data types are  int, short, long, byte, float, double, char, and boolean.   

Type

 

What the hell does that mean?

int

 

An integer between -2,147,483,648 and 2,147,483,647. 

short

 

An integer between -32,768 to 32,767. 

long

 

An integer between -9,223,372,036,854,775,808L to 9,223,372,036,854,775, 807L. 

byte

 

Uses 8 bits to represent a number from -128 to 127

float

 

Represents integers with fractional parts such as 12.3456. Valid values span 6-7 decimal digits

double

 

Valid values span 15 decimal digits.

char   represents single characters between single quotes using Unicode encoding.
boolean   An integer that can be either true or false.

Okay that's enough for now get ready to make your second applet in the next lesson so we can keep this as hands on as possible.

 

 

 

 




   


EmpireSponsor .:is offering Awesome fully loaded Hosting starting at 5$ 500-2056 Megs PHP! CGI! ASP! SSL Secure Server SQL!
 

 

.:Tutorials:.

HTML
CSS
Javascript
Java
Flash
PSP
Support Forum
 

.:Tools:.

Free Search Engine Submission
Meta tag generator
 

.:Tests:.

CSS validator
HTML validator
Website Garage
HTML Doctor
 
.: Search :.
Need To Find Something Fast?
© 2002-2003 Empireezine.tripod.com