This repository contains all code done during lectures.
- Inhretance Lecture 01, Lecture 02
- Access modifier Lecture 02
- Pass by Value Lecture 02
- Pass by Reference Lecture 02
- Method Overloading Lecture 02
Here the class diagram for all IO Stream

- User Input using
System.inandScanner- String Parser using
StringTokenizerLecture 03
- String Parser using
- Text File
- Write text file using
FileOutputStreamLecture 02BufferedOutputStreamLecture 02PrintWriterand read user input usingSystem.inandScannerLecture 04
- Read text file using
FileInputStreamand array of byte- Read part of a text file (no loop) Lecture 03
- Read whole text file (general reader) Lecture 03
- Read text file using
BufferedReaderandInputStreamReaderLecture 04
- Write text file using
- Binary File with fixed string an example of data recored (int, char[15], double)
- Write binary file
- using
DataOutputStreamLecture04
- using
- Read binary file using
DataInputStream- read single recored from file by moving file currsor into specifc position in the file Lecture 04
- read whole file recored by recored until reaching end of file using
EOFExceptionLecture 04
- Write binary file
- Using input
markandresetfromBufferedInputStreamLecture 05 - Read/Write binary file using
RandomAccessFileLecture 05 - Binary file simulate database management system that include (add/edit/delete/search) using
RandomAccessFileLecture 06 Fileusage:- Reterive file information and check its existance Lecture 07
- Create new file and delete it Lecture 07
- Create new Directory and delete it using Lecture 07
- Using
JFileChooserand list selected directory files Lecture 07 - List all files and directories and sub-directories recursively as a tree Lecture 07
- Working with class instance to be stored/read in/from a file using
ObjectOutputStreaandObjectInputStreamLecture 09- First you make sure your class is serializable (
implements Serializable)- example Student class Lecture 09
- Write Object onto file Lecture 09
- Read Several stored objects from a binary file Lecture 09
- First you make sure your class is serializable (
- Throw an exception to stop recursion backword Lecture 08
- Unexpected result when using return within a finally block Lecture 08
- Custom Exception Lecture 08
- Custom uncheck exception (RuntimeException) Lecture 10 NegativeAmountException
- Custom uncheck exception (RuntimeException) Lecture 10 SameAccountException
- using above custom exceptions Lecture 10 Bank, Lecture 10 ATM
- Example of calculating the sum of an array using:
- signle thread - main thread Lecture 09
- multithreads Lecture 09
- Example of shared resource between threads:
- Counter: Two threads increasing static variable shared between them. Each thread increases the
counter1000000 times, so the final value ofcounterafter both threads should be 2000000- incorrect way to increase a counter using several threads Lecture 09
- solve for previous example
- adding synchronized to method signture Lecture 10
- using synchronized block Lecture 10
- Bank and ATM: A bank has several customers' accounts. ATMs use an instance of that bank and call
transfermethod in order to transfere from account to another. Each ATM works as a thread. The transfer occors in the same time which may cause unexpected result. That is, bank instance initilized with number of accounts with initial amount of 1000.0 SAR. Assume that number of accounts is 10. The total balance of the bank should always 1000.0 * 10 = 10000.0; however, do to the concurrent transfer the total bank balance change which it should not.- Unsolved example: Lecture 10
- Solved example:
- using synchronized keyword with
transfermethod signture Lecture 10 - using synchronized block Lecture 10
- using synchronized keyword with
- Counter: Two threads increasing static variable shared between them. Each thread increases the
The workspace contains two folders by default, where:
src: the folder to maintain sourceslib: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the bin folder by default.
If you want to customize the folder structure, open
.vscode/settings.jsonand update the related settings there.
The JAVA PROJECTS view allows you to manage your dependencies. More details can be found here.