2011年5月11日星期三

laptop battery recall fire

Java Programming For Beginners - Characters and printf Characters

In computer terminology, we use the term character to refer to any one of the following:

? a digit from 0 to 9;

? an uppercase letter from A to Z;

? a lowercase letter from a to z;

? a special symbol like (, ), $, =, <, >, + hp pavilion dv4 Battery, -, / Dell Inspiron 1501 Battery, *, etc.

The following are commonly used terms:

letter �C one of a to z or A to Z

lowercase letter �C one of a to z

uppercase letter �C one of A to Z

digit �C one of 0,1,2,3,4,5 Ibm Thinkpad X60 Battery,6,7,8,9

special character �C any symbol except a letter or a digit

e.g. +, <, >, $, &, *, /, =

alphabetic �C used to refer to a letter

numeric �C used to refer to a digit

alphanumeric �C used to refer to a letter or a digit

Characters are the basic building blocks used in writing programs; cheap

we put characters together to form variables and constants;

we put variables, constants and special characters to form expressions such as (a + 2.5) * c;

we add special words such as replacement if, else and while to form statements such as

if (a > 0) b = a + 2;

and we put statements together to form programs.

Welcome to Java Programming

We take a quick shop peek at the Java programming language by writing a program to print, on the screen, the message

Welcome to BrightHub

One solution is the following

public class Welcome {public static void main(String[] args) {System.out.printf("Welcome  cheap  to BrightHub");}
}

A Java program consists of one or more classes. Our sample program consists of one class called Welcome. A class normally contains two kinds of members - variables and methods. A charger variable is used to hold data used by the class. Method is the Java term for a group of statements which perform a subtask, perhaps one of many, which can be executed to help accomplish the task for which the class is written. Other languages use the term gateway function instead of method. Our program contains no variables and one method called main.

For now, the programs we will write must have a method named main which we will write with the following "header":

public  new  static void main(String[ ] args)

The Java interpreter starts executing a program by executing the statements in main. The word public makes this possible; it indicates that main is 'known' (and can be called from) store outside the class in which it is defined. Thus the Java interpreter 'knows' and can 'call' main. The other terms in the header of main will be explained in due course. For now, just think of them as required.

The body of main (the compaq part between the left and right braces) contains one statement:

System.out.printf("Welcome to BrightHub");

When executed, this statement will print

Welcome to BrightHub

on the 'standard output'. For now, take this discount to mean the monitor (screen).

System.out.printf is a standard method which can be used for printing data on the 'standard output'. To be more precise, printf is a method which belongs to the object System.out; for now apple laptop batteries, the acer aspire distinction is not important. For the most part, we will refer to the method simply as printf. In the example, the data to be printed consists of a string (a set of characters enclosed in double quotation marks).

Note: printf was introduced in zxcsky09520 JDK 5.0. It is much more versatile and flexible than the older print and println methods. In this series, we will use printf.

References

Reference text: Java Programming �C A Beginner's Course

Related programming refer

没有评论:

发表评论