office: 339
phone: +48 71 3757836

Office hours (room 339):

  • Tuesday 10-11
  • Wednesday 14-15
Please agree in advance the exact date of consultation by email.

Java - basic course (winter semester of the 2013/2014)


Institute of Computer Science
University of Wrocław
ul. Joliot-Curie 15
50-383 Wrocław

30st December, 2013

The eighth lab:

The task for eighth lab has published.

31st November, 2013

The third lab:

The task for third lab has published.

3rd October, 2013

The first lab:

The first lab will be held until next week on 10 October 2013.

1st October, 2013

The advertising point:

Here is the place where important news on lectures and exercises will be published.

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995. It is an object-oriented programming language. The language derives much of its syntax from C++ but has a simpler object model and fewer low-level facilities.

The main goal of this course is to teach programming in Java and introduction to basic Java technologies.


  • C++ programming language;
  • basic data structures (arrays, lists, trees, graphs).



  • Ken Arnold, James Gosling, David Holmes: The Java Programming Language. Fourth Edition. Prentice Hall PTR, 2005.
  • Herbert Schildt: Java: A Beginner’s Guide. Third Edition. McGraw-Hill, 2005.
  • Joshua Bloh: Effective Java. Second Edition. Sun Microsystems, 2008.
  • Pat Niemeyer, Jonathan Knudsen: Learning Java. Third Edition. O'Reilly Media, 2005.
  • Kathy Sierra, Bert Bates: Head First. Java. Second Edition. O'Reilly Media, 2005.
  • James Gosling, Bill Joy, Guy Steele, Gilad Bracha: The Java Language Specification. Third Edition. Prentice Hall PTR, 2005.
  • Tim Lindholm, Frank Yellin: The Java Virtual Machine Specification. Second Edition. Prentice Hall PTR, 1999.


My secret library - the password: "java"


  • Lecture: Wednesday 10-12, room 139
  • Lab: Wednesday 12-14, room 110


Lab rules

At this site several simple programming tasks will be published. For each properly programmed task the student can score up to 10 points or up to 5 points for the task submitted within a week after the deadline.
The deadline for each task is nearest Wednesday after its publication (Wednesday in the next week). Delays longer than a week are not acceptable. The only exceptions are: illness confirmed by a doctor or official matters confirmed by the appropirate authorities.
Presentation of solutions:
Programs have to be presented during lab sessions, personally by the author (student). It is unacceptable to pass the solutions by colleagues. During the presentation the author should be prepared to answer questions about: the method, specific langauge constructions, technologies, etc. used in the proposed solution.
Presented programs have to be sent to me immediately after the lab sessions. I will collect your programs to the end of semester.
To receive the credit for this course, grade 3 (sufficient), the student has to collect minimum 50% of all the possible points; for grade 5 (very good) it is necessary to collect 90% of all the possible points; the rest of the intermediate grades are linearly dependent on the above border requirements.


  1. 17 Oct, 2013: The number to words converter (pdf)
  2. 24 Oct, 2013: Polynomials (pdf)
  3. 7 Nov, 2013: Expression trees (pdf)
  4. 14 Nov, 2013: The Reverse Polish Notation calculator (pdf)
  5. 28 Nov, 2013: The simple integer calculator (pdf)
  6. 5 Dec, 2013: Colored drawings (pdf)
  7. 19 Dec, 2013: The binary search tree (pdf)
  8. 16 Jan, 2014: Playgrounds in a city park (pdf)
  9. 23 Jan, 2014: Cleaning streams (pdf)
  10. 30 Jan, 2014: Tic Tac Toe (pdf) - an additional exercise



Table of Contents

1: an overview of Java 2: classes and objects 3: inheritance
4: interfaces, inner classes 5: exceptions and assertions 6: AWT, graphics, events
7: Swing - GUI components 8: Swing - the window architecture 9: generics
10: collections, enumerations 11: threads 12: streams
13: applets 14: ... 15: ...
3 October, 2013 (overview of Java)

Recommended reading:

  1. The Java Programming Language (Arnold, Gosling, Holmes): Chapter 1 - A Quick Tour.
  2. Java: A Beginner’s Guide (Schildt): Module 1 - Java Fundamentals.
  3. Java: A Beginner’s Guide (Schildt): Module 2 - Introducing Data Types and Operators.
  4. Java: A Beginner’s Guide (Schildt): Module 3 - Program Control Statements.
  5. Core Java: Fundamentals (Horstmann, Cornell): Chapter 4 - Fundamental Programming Structures in Java.
  6. Getting Started
  7. Object-Oriented Programming Concepts
  8. Language Basics
  9. Java Language Tutorial (by Jakob Jenkov)

The concept of Java:

  • history of Java;
  • JVM - Java virtual mashine;
  • basic features of Java;
  • standard packages;
  • documentation;
  • Java technology;
  • development environment NetBeans 7.3.

Java programming language:

  • the first program in Java;
  • compiling - javac;
  • loading and execution - java;
  • literals, variables, operators, expressions, instructions, comments;
  • primitive types and referenced types;
  • creation new object (operator new) and removing unwanted objects (garbage-collector);
  • wrapper classes for primitive types;
  • the String class;
  • conversion from string to number;
  • arrays and multidimensional arrays;
  • standard input and output;
  • program arguments.
Sample programs:
10 October, 2013 (classes and objects)

Recommended reading:

  1. The Java Programming Language (Arnold, Gosling, Holmes): Chapter 2 - Classes and Objects.
  2. Java: A Beginner’s Guide (Schildt): Module 4 - Introducing Classes, Objects, and Methods.
  3. Core Java: Fundamentals (Horstmann, Cornell): Chapter 4 - Objects and Classes.
  4. Classes and Objects
  5. Java Language Tutorial (by Jakob Jenkov)

Classes and objects:

  • class as a new data type;
  • class definition;
  • class members: fields and methods;
  • reference this;
  • constructors and object initialization;
  • methods and theirs arguments;
  • overloading;
  • methods with a variable number of arguments;
  • final fields;
  • static members;
  • access controll.
17 October, 2013 (inheritance)

Recommended reading:

  1. The Java Programming Language (Arnold, Gosling, Holmes): Chapter 3 - Extending Classes.
  2. Java: A Beginner’s Guide (Schildt): Module 7 - Inheritance.
  3. Core Java: Fundamentals (Horstmann, Cornell): Chapter 5 - Inhereritance.
  4. Interfaces and Inheritance
  5. Java Language Tutorial (by Jakob Jenkov)

Extending classes:

  • base class and extended class;
  • inheritance declaration;
  • a class can extends exactly one another class;
  • the hierarchy of inheritance (class Object is on the top of the hierachy);
  • constructor order dependencies: (1) invoke a superclass's constructor, (2) initialize the fields using their initializers and any initialization blocks; (3) execute the body of the constructor;
  • a constructor in the extended class can directly invoke one of the superclass's constructors using another kind of explicit constructor invocation: the superclass constructor invocation, which uses the super construct;
  • fields cannot be overridden - they can only be hidden;
  • overriding a method means replacing the superclass's implementation of a method with one of your own;
  • upublicznianie składowych;
  • accessing inherited members.


  • type compatibility and conversion;
  • you can test the class of an object by using the instanceof operator;
  • polymorphic method invocation;
  • final methods and classes;
  • abstract classes and methods;
  • the Object class and its methods toString and equals.
24 October, 2013 (interfaces, inner classes)

Recommended reading:

  1. The Java Programming Language (Arnold, Gosling, Holmes): Chapter 4 - Interfaces.
  2. The Java Programming Language (Arnold, Gosling, Holmes): Chapter 5 - Nested Classes and Interfaces.
  3. Java: A Beginner’s Guide (Schildt): Module 8 - Packages and Interfaces.
  4. Core Java: Fundamentals (Horstmann, Cornell): Chapter 6 - Interfaces and Inner Classes.
  5. Interfaces and Inheritance
  6. Java Language Tutorial (by Jakob Jenkov)


  • interfaces define types in an abstract form as a collection of methods or other types that form the contract for that type;
  • interface definition;
  • an interface can declare named constants - these constants are defined as fields but are implicitly public, static, and final;
  • an interface can declare methods - these methods are implicitly public and abstract because no implementation is;
  • extending interfaces;
  • implementing interfaces;
  • adapters;
  • interface Cloneable and cloning objects.

Inner classes:

  • classes and interfaces can be declared inside other classes and interfaces;
  • static nested types;
  • non-static nested classes are called inner classes;
  • anonymous inner classes.
7 November, 2013 (exceptions and assertions)

Recommended reading:

  1. The Java Programming Language (Arnold, Gosling, Holmes): Chapter 12 - Exceptions and Assertions.
  2. Java: A Beginner’s Guide (Schildt): Module 9 - Exception Handling.
  3. Exceptions
  4. Java Exception Handling (by Jakob Jenkov)


  • exceptions provide a mechanism to signal errors directly;
  • the hierarchy of exceptions (the Throwable class);
  • there are two kinds of exception types: checked (those that must be declared in the throws-clause of a method or constructor) and unchecked (those that need not be) which inherit from Error or RuntimeException;
  • throwing exceptions (the throw statement);
  • catching exceptions (the try-catch statement);
  • the finally clause of a try-catch statement provides a mechanism for executing a section of code whether or not an exception is thrown;
  • a catch clause is somewhat like an embedded method that has one parameter namely, the exception to be caught;
  • the throws clause and method overriding;
  • all exceptions you create should extend Exception, making them checked exceptions;
  • exception chaining.


  • assertions are used to check invariants (conditions that should always be true);
  • the assert statement and throwing the error AssertionError;
  • turning assertions on and off.
14 November, 2013 (AWT, graphics, events)

Recommended reading:

  1. Java AWT Reference
21 November, 2013 (Swing - GUI components)

Recommended reading:

  1. Creating a GUI With JFC/Swing
28 November, 2013 (Swing - windows architecture)

Recommended reading:

  1. Creating a GUI With JFC/Swing
5 December, 2013 (generics)

Recommended reading:

  1. Generics (by Gilard Bracha)
  2. Generics (Updated)
  3. Java Generics Tutorial (by Jakob Jenkov)
12 December, 2013 (collections, enumerations)

Recommended reading:

  1. Collections
  2. Java Collections Tutorial (by Jakob Jenkov)


  • a collection - simply an object that groups multiple elements into a single unit;
  • the hierarchy of collections (the Collection and Map interfaces);
  • iterators;
  • sorted collections (the SortedSet and SortedMap interfaces);
  • comparators;
  • implementations of collections;
  • old collections;
  • algorithms performed on collections (the Collections and Arraysclasses).


  • the definition of enum type;
  • how to use an enum type;
  • you can define fields, constructors, and methods inside an enum type.
19 December, 2013 (threads)

Recommended reading:

  1. Concurrency
  2. Java Concurrency / Multithreading Tutorial (by Jakob Jenkov)
  3. java.util.concurrent Tutorial (by Jakob Jenkov)
  4. Java concurrency (multi-threading) - tutorial (by Lars Vogel)
  5. Introduction to Java threads (by Donald G. Drake)
  6. Java Threads Tutorial
9 January, 2014 (streams)

Recommended reading:

  1. Basic I/O
  2. Java IO Tutorial (by Jakob Jenkov)
16 January, 2014 (applets)

Recommended reading:

  1. Java Applets
  2. Java Applet Tutorial (
  3. Java Applet Tutorial (
  4. Java - Applet Basics (

Instytut Informatyki