0% found this document useful (0 votes)
131 views

Dasar-Dasar Pemrograman 2: Java Basics: Fariz Darari (Fariz@cs - Ui.ac - Id)

1) The document introduces basic concepts of programming in Java, including problem solving, compiling and running Java programs, and printing "Hello World". 2) It discusses key Java concepts like variables, arithmetic operators, and different types of errors like compile-time, runtime, and logic errors. 3) The document is based on chapters 1 and 2 from the Think Java book and aims to provide an introduction to Java basics.

Uploaded by

Pembelajar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views

Dasar-Dasar Pemrograman 2: Java Basics: Fariz Darari (Fariz@cs - Ui.ac - Id)

1) The document introduces basic concepts of programming in Java, including problem solving, compiling and running Java programs, and printing "Hello World". 2) It discusses key Java concepts like variables, arithmetic operators, and different types of errors like compile-time, runtime, and logic errors. 3) The document is based on chapters 1 and 2 from the Think Java book and aims to provide an introduction to Java basics.

Uploaded by

Pembelajar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Dasar-Dasar Pemrograman 2:

Java Basics
Fariz Darari ([email protected])

Feel free to use, reuse, and share this work:


the more we share, the more we have!
Problem solving
• The single most important skill for a computer scientist is
problem solving.
• It's the ability to:
• formulate problems,
• think creatively about solutions, and
• express solutions clearly and accurately.
• As it turns out, the process of learning to program is an excellent
opportunity to develop problem solving skills.
Compiling and running a Java
program

• Java is both compiled and interpreted.


• Instead of translating programs directly into machine language,
the Java compiler generates byte code.
• Similar to machine language, byte code is easy and fast to interpret.
• But it is also portable, so it is possible to compile a Java program on one machine,
transfer the byte code to another machine, and run the byte code on the other machine.
• The interpreter that runs byte code is called a "Java Virtual Machine" (JVM).
Hello, World!
Escape sequences
Escape sequences
We could write something like this,
but..
We could write something like this,
but..

This one reads better :)


Quiz time
• What is a program?

• What is a bug?

• What is compile?
Quiz time
• What is a program?
A sequence of instructions that specifies how to perform tasks on a computer.
• What is a bug?
An error in a program.
• What is compile?
To translate a program in a high-level language into a low-level language,
all at once, in preparation for later execution.
Variables
• A variable is a named location that stores a value. Values may be
numbers, text, images, sounds, and other types of data.
Declaration

Assignment
Declare and assign variables on
same line
Printing variables
Arithmetic operators
Floating-point numbers
Error types
• Compile-time error
Compile-time errors occur when you violate the syntax rules of the Java
language. For example, parentheses and braces have to come in matching
pairs. So (1 + 2) is legal, but 8) is not.
• Runtime error
The second type of error is a run-time error, so-called because it does not
appear until after the program has started running.
• Logic error
If your program has a logic error, it will compile and run without generating
error messages, but it will not do the right thing.
Credits: Chapter 1 and 2 of Think Java book by Allen Downey and Chris Mayfield

You might also like