Introduction to Java - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Java

Description:

Learn enough Java to do something useful Examples: Simulate a natural/engineering process Manipulate PDFs Draw pretty graphics. For more information about java programming, visit: . – PowerPoint PPT presentation

Number of Views:0
Date added: 20 September 2024
Slides: 25
Provided by: AmeliaPeterson
Tags:

less

Transcript and Presenter's Notes

Title: Introduction to Java


1
Introduction to Java
1 Types, Variables, Operators
2
Goal
  • Learn enough Java to do something useful
  • Examples
  • Simulate a natural/engineering process
  • Manipulate PDFs
  • Draw pretty graphics

3
Assignments
  • View and submit via Stellar
  • Due at 3 PM the next day (24 hours)
  • Collaborate with others
  • Write your own code
  • Must submit first assignment
  • Must submit a reasonable attempt for 6/7
    assignments to pass

4
The Computer
Memory
Central Processing Unit (CPU)
Input/Output (IO) Devices
5
CPU Instructions
Read location x Read location y Add Write to
location z
z x y
6
Programming Languages
  • Easier to understand than CPU instructions
  • Needs to be translated for the CPU to understand
    it

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

8
Compiling Java
Source Code (.java)
Byte Code (.class)
javac
java
9
First Program
  • class Hello
  • public static void main(String arguments)
  • // Program execution begins here
    System.out.println("Hello world.")

10
Program Structure
  • class CLASSNAME
  • public static void main(String arguments)
  • STATEMENTS

11
Output
System.out.println(some String) outputs to the
console Example System.out.println(output)
12
Second Program
  • class Hello2
  • public static void main(String arguments)
    System.out.println("Hello world.") // Print once
    System.out.println("Line number 2") // Again!

13
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).
14
Variables
Named location that stores a value of one
particular type. Form TYPE NAME Example
String foo
15
Assignment
Use to give variables a value. Example String
foo foo IAP 6.092
16
Assignment
Can be combined with a variable
declaration. Example double badPi 3.14
boolean isJanuary true
17
class Hello3 public static void main(String
arguments) String foo "IAP 6.092"
System.out.println(foo) foo "Something
else" System.out.println(foo)
18
Operators
Symbols that perform simple computations Assignme
nt Addition Subtraction - Multiplication
Division /
19
Order of Operations
  • Follows standard math rules
  • Parentheses
  • Multiplication and division
  • Addition and subtraction

20
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)
21
class DoMath2 public static void main(String
arguments) double score 1.0 2.0 3.0
System.out.println(score) double copy
score copy copy / 2.0 System.out.println(copy)
System.out.println(score)
22
String Concatenation ()
String text "hello" " world" text text "
number " 5 // text "hello world number 5"
23
Assignment GravityCalculator
Compute the position of a falling object x(t)
0.5 at2 vit xi
24
Introduction to Programming https//www.expertsmi
nds.com/content/sample-paper/hs1031-introduction-t
o-programming-assignment-help-14012.html
For more information about java programming,
visit https//www.expertsminds.com/content/java-p
rogramming-assignment-help-39321.html.
Write a Comment
User Comments (0)
About PowerShow.com