Java Basics

Java Basics

On Days 1 and 2, you learned about Java programming in very broad terms—what a Java
program and an executable look like, and how to create simple classes. For the remainder of this
week, you’re going to get down to details and deal with the specifics of what the Java language
looks like.
Today, you won’t define any classes or objects or worry about how any of them communicate
inside a Java program. Rather, you’ll draw closer and examine simple Java statements—the basic
things you can do in Java within a method definition such as main().
Today you’ll learn about the following:
n Java statements and expressions
n Variables and data types
n Comments
n Literals
n Arithmetic
n Comparisons
n Logical operators
Technical Note: Java looks a lot like C++, and—by extension—like C. Much of
the syntax will be very familiar to you if you are used to working in these languages.
If you are an experienced C or C++ programmer, you may want to pay special
attention to the Technical Notes (such as this one), because they will provide
information about the specific differences between these and other traditional
languages and Java.
Statements and Expressions
A statement is the simplest thing you can do in Java; a statement forms a single Java operation.
All the following are simple Java statements:
int i = 1;
import java.awt.Font;
System.out.println(“This motorcycle is a “
+ color + “ “ + make);
m.engineState = true;
Statements sometimes return values—for example, when you add two numbers together or test
to see whether one value is equal to another. These kind of statements are called expressions.
We’ll discuss these later on today.


Variables and Data Types
Variables are locations in memory in which values can be stored. They have a name, a type, and
a value. Before you can use a variable, you have to declare it. After it is declared, you can then
assign values to it.


Comments

Popular posts from this blog

'composer' is not recognized as an internal or external command in windows server

lEARN :: SQL | Views