0% found this document useful (0 votes)
1K views1 page

Teach Yourself Java in 21 Minutes: Department of Computer Science, Lund Institute of Technology

This document provides a brief tutorial on the Java programming language intended for readers familiar with object-oriented languages like C++. It presents the essential elements of Java through examples and is intended to provide enough information to follow a course on real-time programming in just 21 minutes, as claimed by the title. The tutorial covers topics like simple declarations, statements, classes and objects, exceptions, and a complete Java program.

Uploaded by

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

Teach Yourself Java in 21 Minutes: Department of Computer Science, Lund Institute of Technology

This document provides a brief tutorial on the Java programming language intended for readers familiar with object-oriented languages like C++. It presents the essential elements of Java through examples and is intended to provide enough information to follow a course on real-time programming in just 21 minutes, as claimed by the title. The tutorial covers topics like simple declarations, statements, classes and objects, exceptions, and a complete Java program.

Uploaded by

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

Teach Yourself Java in 21 Minutes

Department of Computer Science, Lund Institute of Technology


Author: Patrik Persson Contact: [email protected]

This is a brief tutorial in Java for you who already know


another object-oriented language, such as Simula or C++.
The tutorial is organized as a number of examples showing
the details of Java. The intention is to give you enough
information about the Java language to be able to follow the
course in real-time programming.
There are books claiming to teach you Java in 21 days, but
since you already know object-orientation your learning
time will probably be closer to 21 minutes hence the title.
This document may be freely copied and distributed for non-commercial use. In case of
changes or enhancements, title, department, author, and contact must be preserved, and
changes that are redistributed or made public must be mailed to the contact above.

Table of contents
1 Simple declarations and expressions .......................................................................3
1.1 Simple declarations..............................................................................................................3
1.2 Numeric expressions and assignments.................................................................................3
1.3 Type conversion (casting) ....................................................................................................4
2 Statements ................................................................................................................4
2.1 If statements and boolean expressions .................................................................................5
2.2 While and for statements .....................................................................................................6
3 Classes and objects ..................................................................................................6
3.1 Classes..................................................................................................................................7
3.2 Methods................................................................................................................................7
3.3 Using objects........................................................................................................................8
3.4 Parameters to classes: constructors ......................................................................................8
3.5 The main method .................................................................................................................9
3.6 Inheritance............................................................................................................................9
3.7 Interfaces and listeners.......................................................................................................10
4 Exceptions..............................................................................................................11
4.1 Catching exceptions ...........................................................................................................11
4.2 Throwing exceptions..........................................................................................................12
4.3 Declaring new exceptions ..................................................................................................12
4.4 Unchecked exceptions........................................................................................................13
5 Miscellaneous ........................................................................................................13
5.1 Comments ..........................................................................................................................13
5.2 Using packages ..................................................................................................................13
5.3 Arrays.................................................................................................................................14
5.4 Writing to the terminal.......................................................................................................14
6 A complete Java program ......................................................................................15

Teach Yourself Java in 21 Minutes 1

You might also like