Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
186 views

ComProg1 Lesson 2 - Introduction To Programming

Java was created in 1991 by James Gosling at Sun Microsystems to control home appliances from a variety of processors. It later became ideal for use in web browsers when Netscape incorporated it in 1995. Java's name came from the fact that Oak was already taken, so the team named it Java after going for coffee. The document introduces Java programming terminology like classes, methods, variables, and data types. It also covers naming conventions for variables and rules for input and output in Java programs.

Uploaded by

Jofrank Riego
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views

ComProg1 Lesson 2 - Introduction To Programming

Java was created in 1991 by James Gosling at Sun Microsystems to control home appliances from a variety of processors. It later became ideal for use in web browsers when Netscape incorporated it in 1995. Java's name came from the fact that Oak was already taken, so the team named it Java after going for coffee. The document introduces Java programming terminology like classes, methods, variables, and data types. It also covers naming conventions for variables and rules for input and output in Java programs.

Uploaded by

Jofrank Riego
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lesson 2: Introduction to Programming

I. Brief history of Java Programming Language


Java, having been developed in 1991, is a relatively new programming language. At that time,
James Gosling from Sun Microsystems and his team began designing the first version of Java
aimed at programming home appliances which are controlled by a wide variety of computer
processors.

Gosling's new language needed to be accessible by a variety of computer processors. In 1994,


he realized that such a language would be ideal for use with web browsers and Java's
connection to the internet began. In 1995, Netscape Incorporated released its latest version of
the Netscape browser which was capable of running Java programs.

Why is it called Java? It is customary for the creator of a programming language to name the
language anything he/she chooses. The original name of this language was Oak, until it was
discovered that a programming language already existed that was named Oak. As the story
goes, after many hours of trying to come up with a new name, the development team went out
for coffee and the name Java was born.

II. Terminologies:
a. Computer Program – a sequence of statements intended to accomplish a task.
b. Programming – process of planning and creating a program.
c. Programming Language – set of rules, symbols, and special words used to construct
programs.
d. Class – used to create Java programs. It is used to group a set of related operations.
e. Method – a Java mechanism where operations in a program is implemented.
f. Identifier – names of things, such as variables, constants and methods, that appear in
programs.
g. Variable – memory cells whose contents can be modified during program execution.
h. Declaration – declare things such as variable; naming and identifying the data type of a
variable.
i. Initialization – placing for the first time the value of a variable.
j. Debugging – removing the errors in a program.
k. Reserved Words are names that cannot be used for anything other than their intended
use. (Example: int, double, char, boolean etc.)
III. Rules in naming Java variables
a. Variable names are case-sensitive. A variable's name can be any legal identifier — an
unlimited-length sequence of Unicode letters and digits, beginning with a letter, the
dollar sign "$", or the underscore character "_". The convention, however, is to always
begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign
character, by convention, is never used at all. You may find some situations where auto-
generated names will contain the dollar sign, but your variable names should always
avoid using it. A similar convention exists for the underscore character; while it's

New Era University


Computer Programming 1 Page 1
Lesson 2: Introduction to Programming

technically legal to begin your variable's name with "_", this practice is discouraged.
White space is not permitted.
b. Subsequent characters may be letters, digits, dollar signs, or underscore characters.
Conventions (and common sense) apply to this rule as well. When choosing a name for
your variables, use full words instead of cryptic abbreviations. Doing so will make your
code easier to read and understand. In many cases it will also make your code self-
documenting; fields named cadence, speed, and gear, for example, are much more
intuitive than abbreviated versions, such as s, c, and g. Also keep in mind that the name
you choose must not be a keyword or reserved word.
c. If the name you choose consists of only one word, spell that word in all lowercase
letters. If it consists of more than one word, capitalize the first letter of each subsequent
word. The names gearRatio and currentGear are prime examples of this convention. If
your variable stores a constant value, such as static final int NUM_GEARS = 6, the
convention changes slightly, capitalizing every letter and separating subsequent words
with the underscore character. By convention, the underscore character is never used
elsewhere. (Camelized)
IV. Java Primitive Data Types
a. char (16 bits)
b. byte (8 bits)
c. short (16 bits)
d. int (32 bits)
e. long (64 bits)
f. boolean (true or false)
g. float (6 or 7 decimal points)
h. double (15 decimal points)
V. Input and Output
a. Output
i. System.out.print();
ii. System.out.println();
iii. BufferedWriter
b. Input
i. BufferedReader
ii. Scanner Class
1. Code:
import java.util.*;
Scanner console = new Scanner (System.in);
console.next(); nextLine(); nextInt(); nextDouble();

New Era University


Computer Programming 1 Page 2

You might also like