Differences between Java and Java Script Programming languages

Differences between Java and Java. Script Programming languages PART 2

Reading in values Java. Script Java Read the type of variable to input First, import the Scanner class // Read a string import java. util. Scanner; var str = read. Line(prompt); 2 nd create a Scanner object // Read an integer var num = read. Int(prompt); Scanner scan = new Scanner(System. in); // Read a float Then read in the type of variable var cost = read. Float(prompt); int num = scan. next. Int(); // Read a boolean double d = scan. next. Double(); var bool = read. Boolean(prompt); String s = scan. next. Line();

How the language is used Java. Script Java Runs inside a web page Create applets or programs Part of the page Stand alone Interpreted by the browser Runs in a virtual machine for each kind of processor Nothing to install Install the JRE (Java runtime environment) to run code, install the JDK (Java Developers Kit) to write code, install and IDE to develop code.

Conditionals Essentially the same Use the comparison and logical operators: || , && , =< , => , < , > , =! , == if(boolean condition){ statement; } else { statement{ ; If , if/else if/…/else

Repeat with condition Basically the same while (boolean condition){ statements; }

Repeat a fixed number of times Java. Script for ( var i = 0; i< limit ; i++){ statements; } Java for ( int i = 0; i< limit ; i++){ statements; }
- Slides: 6