Professional Documents
Culture Documents
Java Basics
Agenda
1.
Output 2. Input in
Java 3. Casting
in Java
Java Basics
1. Output in Java
Print an object
System.out.print(Object object);
Java Basics
System.out is the "standard" java output stream
System.out.print();
Print without moving cursor
to the next line
System.out.println();
Print moving cursor to the next
line
Java Basics
System.out is the "standard" java output stream
Java Basics
System.out is the "standard" java output stream
System.out.printf();
Print without moving cursor to the next line
Java Basics
1.2 Escape Sequences
Java Basics
Escape sequences
Java Basics
Escape sequences: new line and tab examples
Java Basics
Escape sequences: slash and double quote
examples
Java Basics
1.3 Integers
Java Basics
Printing formats: Numbers with zeros
This is the
format
Java Basics
Printing Integers Numbers
Printing Integers Numbers
Java Basics
1.4 Floats
Java Basics
Printing formats: Floats
This is the
format
Java Basics
Printing Floating-Point Numbers
Java Basics
Printing Floating-Point Numbers
Java Basics
1.5 Chars and Strings
Java Basics
Printing formats: Letters
This is the
format
Java Basics
Printing Strings and characters
Java Basics
Printing Strings and characters
Java Basics
1.6 Dates and Times
Java Basics
Printing Dates and times
Java Basics
Printing Dates and times
Java Basics
Printing formats: Dates
Remember
to import
the Date
Class
This is the
format
Java Basics
Printing formats resources
Java Basics
2. Input in Java
Java Basics
System.in is used to read user inputs
Java Basics
System.in: reading strings example
Creating the
scanner
Reading
an integer
Java Basics
System.in: reading strings example
Creating the
scanner
Reading
a String
Java Basics
System.in: reading posibilities
Java Basics
3. Casting
Assignation variable
int long float double char byte short boolean
int - A A A C C C N
long C - A A C C C N
float C C - A C C C N
Value double C C C - C C C N
to
assign char A A A A - C C N
byte A A A A C - A N
short A A A A C C - N
boolean N N N N N N N -
Java Basics
ASCII table
Java Basics
References
• [Deitel] H.M. Deitel and P.J. Deitel, Java How to Program: Early
Objects Version, Prentice Hall, 2009.
Java Basics