Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Java Programming Basics: Types, Variables, Operators, and Assignments, Slides of Network security

An introduction to java programming, covering the basics of types, variables, operators, and assignments. It includes examples of cpu instructions, programming languages, compiling java, and writing simple java programs. Students will learn how to declare variables, perform assignments, and use operators for simple computations.

Typology: Slides

2012/2013

Uploaded on 04/22/2013

sathaye
sathaye 🇮🇳

4.8

(8)

106 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
!
1: Types, Variables, Operators"
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Java Programming Basics: Types, Variables, Operators, and Assignments and more Slides Network security in PDF only on Docsity!

1: Types, Variables, Operators

Goal

Learn enough Java to do something

useful

Examples:

  • Simulate a natural/engineering process
  • Manipulate PDFs
  • Draw pretty graphics

The Computer

Central Processing Unit (CPU)

Input/Output (IO) Devices

Memory

CPU Instructions

z = x + y Read location x

Read location y

Add

Write to location z

Java

  • “Most popular” language
  • Runs on a “virtual machine” (JVM)
  • More complex than some (eg. Python)
  • Simpler than others (eg. C++)

Compiling Java

Source Code (.java)

Byte Code javac (^) (.class) java

Program Structure

class CLASSNAME {

public static void main ( String [] arguments ) { STATEMENTS }

}

Output

System.out.println( some String ) outputs to

the console

Example:

System.out.println(“output”);

Types

Kinds of values that can be stored and

manipulated.

boolean : Truth value ( true or false ).

int : Integer (0, 1, -47).

double : Real number (3.14, 1.0, -2.1).

String : Text (“hello”, “example”).

Variables

Named location that stores a value of one

particular type.

Form:

TYPE NAME ;

Example:

String foo;

Assignment

Can be combined with a variable

declaration.

Example:

double badPi = 3.14;

boolean isJanuary = true;

class Hello3 {

public static void main ( String [] arguments ) { String foo = "IAP 6.092" ; System. out. println ( foo ); foo = "Something else" ; System. out. println ( foo ); }

}

Order of Operations

Follows standard math rules:

  1. Parentheses
  2. Multiplication and division
  3. Addition and subtraction

class DoMath {

public static void main ( String [] arguments ) {

double score = 1.0 + 2.0 * 3.0 ;

System. out. println ( score );

score = score / 2.0 ;

System. out. println ( score );