Escolar Documentos
Profissional Documentos
Cultura Documentos
Used to create animations or Used to create applications that run interactive games while working with on any platform, including the web, programming constructs. using Java syntax. Drag and drop interface designed to IDE helps you objects model real reduce syntax errors and make world objects, allow for re-use and learning programming easier. easier maintenance.
public class HelloWorld { public static void main() { System.out.println( "Hello World!" ); } }
Variables in Alice
A typical application uses various values and these values continuously change while the program is running. For example, if you program a car to roll over a certain number of times in Alice 3, the value entered by one user may be different from the value entered by another user.
Variables in Java
In Java, you declare variables that can then be referenced in other parts of the program.
public class Print{ public static void main(String[] args){ int i=1; int j; i and j are variables that are while(i<=7) declared here. { for(j=1;j<=i;j++) system.out.print("*"); i=i+2; i and j are called in system.out.println(); the program body } } }
10
Object Other
11
12
13
14
float
4 bytes
double
8 bytes
15
+ + + + +
18
Relational Operators
A relational operator is a lexical unit used to express a relation, such as equality or greater than, between two expressions. Two suitable expressions combined with a relational operator often form a relational expression or condition in a programming language.
19
20
21
22
Logical Operators
Logical operators are the boolean operators (AND, OR and NOT). Expressions written with logical operators result in TRUE or FALSE.
23
24
The && and || logical operators are sometimes called short-circuted operators.
25
27
28
29
30
Terminology
Key terms used in this lesson included: Arithmetic operators Assignment operators Data type Logical operators Relational operators Variable
32
Summary
In this lesson, you learned how to: Describe variables Describe Java simple types Define arithmetic operators Describe relational and logical operators Describe assignment operators
33
Practice
The exercises for this lesson cover the following topics: Create an animation to demonstrate the use of variables and simple types Create an animation to demonstrate the use of arithmetic, relational, and logical operators Create a Java syntax cheat sheet
34