SlideShare a Scribd company logo
2016 Winter
LAB #1
Prepared by: Berk Soysal
• As of 2015, Java is one of the most popular
programming languages in use.
• https://en.wikipedia.org/wiki/Measuring_programming_language_popularity
• Java is an Object-Oriented Programming Language.
• Structurally, the Java language starts with packages.
A package is the Java language's namespace
mechanism. Within packages are classes, and within
classes are methods, variables, constants, and
more.
2016 Winter
Project Name
Package Name
Java File
Dog Class
Class Variables
Constructor Method
Other User Defined
Methods
2016 Winter
• An object is a self-contained entity that contains attributes and
behavior.
• Every program must contain a main method, public static
void main(String[] args).
• Java is a strongly typed language. You must declare the type
of each variable.
• Every instruction ends with a semi-column “;”.
• Instructions that belong to the same block must be between
curly brackets “{. . .}”.
• Now, let’s have a look at the indentation and comments.
2016 Winter
2016 Winter
http://www.drjava.org/
2016 Winter
https://www.eclipse.org/downloads/
if(condition1 == condition2){
while(condition3!=false){
if(condition3==condition4){
doSomethingAboutIt();
System.out.println(“Something");
}
else{
doNotDoSomethingAboutIt();
System.out.println(“Nothing");
}
}
}
if(condition1 == condition2){
while(condition3!=false){
if(condition3==condition4){
doSomethingAboutIt();
System.out.println(“Something");
}
else{
doNotDoSomethingAboutIt();
System.out.println(“Nothing");
}
}
}
2016 Winter
// This is a single line comment
if (a == 2) {
return TRUE; /* First block comment here*/
}
else {
return verifyInteger(a); /* Your next block comment here*/
}
// Use as many comments as possible, explain everything
// in your code.
/* Otherwise you will forget what you have written after
a period of time */
Download this ppt. - http://uottawa.ml2016 Winter
2016 Winter
2016 Winter
• For the indentation in DrJava; you need to select
your code, and press on the TAB key on the
keyboard.
• Please always use comments in your code to
explain your steps.
2016 Winter
2016 Winter
• Java Compiler: javac is the executable/application which
compiles the .java source files into the byte code (.class
files).
• Java Run-time Environment (JRE): Java Run-time
Environment helps in running the programs. JRE contains
the JVM, the java classes/packages and the run-time
libraries.
• Java Virtual Machine (JVM): Java Virtual Machine is
important part of the JRE, which actually runs the programs
(.class files), it uses the java class libraries and the run-time
libraries to execute those programs.
2016 Winter
Let’s open a notepad document and start writing
our code.
Open the Command Line Interface and Compile;
 javac Main.java
public class Main{
public static void main(String[] args){
System.out.println("Hello World!");
}
}
2016 Winter
After compilation, run the Program
 java Main
Observe the output!
Let’s modify our code so that we can input 3
Strings to the main method!
public class Main{
public static void main(String[] args){
System.out.println("Hello World!");
System.out.println(“Entered Strings: "+args[0]+args[1]+args[2]);
}
}
2016 Winter
Now, let’s run the same program in DrJava..
Let’s compile and run again;
 javac Main.java
 java Main I am YourName
Observe the output!
2016 Winter
Click on Compile first, then Run
2016 Winter
Write a program called Command.java that gives the following output:
What if the number of String inputs is not fixed?
How can we print them??
2016 Winter
For Quiz Question 1
You can use DrJava as well as Command
Line Interface
2016 Winter
Write the program ArrayTool described below. Test with several values
for “cutOffValue” to ensure that your program works.
2016 Winter
Write the program ArrayTool described below. Test with several values
for “cutOffValue” to ensure that your program works.
2016 Winter
2016 Winter
2016 Winter

More Related Content

PPTX
Introduction to ASP.NET
ODP
OOP java
PPTX
If else statement in c++
PDF
Basics of JavaScript
PPTX
LINQ in C#
PPTX
Method overloading
PPTX
Statements and Conditions in PHP
PPT
Java interfaces
Introduction to ASP.NET
OOP java
If else statement in c++
Basics of JavaScript
LINQ in C#
Method overloading
Statements and Conditions in PHP
Java interfaces

What's hot (20)

PPTX
Data types in java
PPTX
ASP.NET Page Life Cycle
PPTX
Loops PHP 04
PPTX
Java virtual machine
PPTX
Java Hello World Program
PPT
PHP - Introduction to Object Oriented Programming with PHP
PPTX
PDF
Introduction to java (revised)
PDF
Nodejs presentation
PPTX
Object Oriented Programming Concepts for beginners
PPTX
How Hashmap works internally in java
PPTX
Control Statements in Java
PPT
Abstract class in java
PPTX
PHP FUNCTIONS
PDF
Spring MVC Framework
PDF
JavaScript - Chapter 10 - Strings and Arrays
PPTX
Looping statement
PPT
Java Basics
PPTX
Control flow statements in java
Data types in java
ASP.NET Page Life Cycle
Loops PHP 04
Java virtual machine
Java Hello World Program
PHP - Introduction to Object Oriented Programming with PHP
Introduction to java (revised)
Nodejs presentation
Object Oriented Programming Concepts for beginners
How Hashmap works internally in java
Control Statements in Java
Abstract class in java
PHP FUNCTIONS
Spring MVC Framework
JavaScript - Chapter 10 - Strings and Arrays
Looping statement
Java Basics
Control flow statements in java
Ad

Viewers also liked (13)

PPTX
Java Tutorial Lab 7
PPTX
Java Tutorial Lab 3
PPTX
Java Tutorial Lab 2
PPTX
Java Tutorial Lab 4
PPTX
Java Tutorial Lab 8
PPTX
Self Evaluation Test
PPTX
Java Tutorial Lab 9
PPTX
Java Tutorial Lab 6
PPTX
Java Tutorial Lab 5
PPT
Behavior Management Part 2
PPT
Java tutorial for Beginners and Entry Level
PDF
Chapter12 - Designing System Interfaces, Controls and Security(Demo Presentat...
PPT
Java tutorial PPT
Java Tutorial Lab 7
Java Tutorial Lab 3
Java Tutorial Lab 2
Java Tutorial Lab 4
Java Tutorial Lab 8
Self Evaluation Test
Java Tutorial Lab 9
Java Tutorial Lab 6
Java Tutorial Lab 5
Behavior Management Part 2
Java tutorial for Beginners and Entry Level
Chapter12 - Designing System Interfaces, Controls and Security(Demo Presentat...
Java tutorial PPT
Ad

Similar to Java Tutorial Lab 1 (20)

PDF
java notes.pdf
PPTX
Java introduction
PPTX
PPTX
1 java programming- introduction
PPTX
Java programming language
PPTX
UNIT 1.pptx
PPT
j-chap1-Basics.ppt
DOCX
java introduction.docx
PDF
Core Java Tutorial
PPTX
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
PPTX
Learn java theory presentation
PDF
Java notes | All Basics |
PDF
Java trainingcourse(1)
PPTX
Introduction to java
PPTX
Mpl 1
PPT
Java introduction
PPTX
What is Java, JDK, JVM, Introduction to Java.pptx
PPTX
Chapter One Basics ofJava Programmming.pptx
PPT
Java basics
java notes.pdf
Java introduction
1 java programming- introduction
Java programming language
UNIT 1.pptx
j-chap1-Basics.ppt
java introduction.docx
Core Java Tutorial
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
Learn java theory presentation
Java notes | All Basics |
Java trainingcourse(1)
Introduction to java
Mpl 1
Java introduction
What is Java, JDK, JVM, Introduction to Java.pptx
Chapter One Basics ofJava Programmming.pptx
Java basics

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
DOCX
The Five Best AI Cover Tools in 2025.docx
PPTX
Transform Your Business with a Software ERP System
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Online Work Permit System for Fast Permit Processing
PDF
medical staffing services at VALiNTRY
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
System and Network Administration Chapter 2
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Wondershare Filmora 15 Crack With Activation Key [2025
The Five Best AI Cover Tools in 2025.docx
Transform Your Business with a Software ERP System
How to Migrate SBCGlobal Email to Yahoo Easily
Understanding Forklifts - TECH EHS Solution
Online Work Permit System for Fast Permit Processing
medical staffing services at VALiNTRY
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Materi_Pemrograman_Komputer-Looping.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Internet Downloader Manager (IDM) Crack 6.42 Build 41
VVF-Customer-Presentation2025-Ver1.9.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
System and Network Administration Chapter 2
ManageIQ - Sprint 268 Review - Slide Deck
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo POS Development Services by CandidRoot Solutions

Java Tutorial Lab 1

  • 1. 2016 Winter LAB #1 Prepared by: Berk Soysal
  • 2. • As of 2015, Java is one of the most popular programming languages in use. • https://en.wikipedia.org/wiki/Measuring_programming_language_popularity • Java is an Object-Oriented Programming Language. • Structurally, the Java language starts with packages. A package is the Java language's namespace mechanism. Within packages are classes, and within classes are methods, variables, constants, and more. 2016 Winter
  • 3. Project Name Package Name Java File Dog Class Class Variables Constructor Method Other User Defined Methods 2016 Winter
  • 4. • An object is a self-contained entity that contains attributes and behavior. • Every program must contain a main method, public static void main(String[] args). • Java is a strongly typed language. You must declare the type of each variable. • Every instruction ends with a semi-column “;”. • Instructions that belong to the same block must be between curly brackets “{. . .}”. • Now, let’s have a look at the indentation and comments. 2016 Winter
  • 7. if(condition1 == condition2){ while(condition3!=false){ if(condition3==condition4){ doSomethingAboutIt(); System.out.println(“Something"); } else{ doNotDoSomethingAboutIt(); System.out.println(“Nothing"); } } } if(condition1 == condition2){ while(condition3!=false){ if(condition3==condition4){ doSomethingAboutIt(); System.out.println(“Something"); } else{ doNotDoSomethingAboutIt(); System.out.println(“Nothing"); } } } 2016 Winter
  • 8. // This is a single line comment if (a == 2) { return TRUE; /* First block comment here*/ } else { return verifyInteger(a); /* Your next block comment here*/ } // Use as many comments as possible, explain everything // in your code. /* Otherwise you will forget what you have written after a period of time */ Download this ppt. - http://uottawa.ml2016 Winter
  • 11. • For the indentation in DrJava; you need to select your code, and press on the TAB key on the keyboard. • Please always use comments in your code to explain your steps. 2016 Winter
  • 13. • Java Compiler: javac is the executable/application which compiles the .java source files into the byte code (.class files). • Java Run-time Environment (JRE): Java Run-time Environment helps in running the programs. JRE contains the JVM, the java classes/packages and the run-time libraries. • Java Virtual Machine (JVM): Java Virtual Machine is important part of the JRE, which actually runs the programs (.class files), it uses the java class libraries and the run-time libraries to execute those programs. 2016 Winter
  • 14. Let’s open a notepad document and start writing our code. Open the Command Line Interface and Compile;  javac Main.java public class Main{ public static void main(String[] args){ System.out.println("Hello World!"); } } 2016 Winter
  • 15. After compilation, run the Program  java Main Observe the output! Let’s modify our code so that we can input 3 Strings to the main method! public class Main{ public static void main(String[] args){ System.out.println("Hello World!"); System.out.println(“Entered Strings: "+args[0]+args[1]+args[2]); } } 2016 Winter
  • 16. Now, let’s run the same program in DrJava.. Let’s compile and run again;  javac Main.java  java Main I am YourName Observe the output! 2016 Winter
  • 17. Click on Compile first, then Run 2016 Winter
  • 18. Write a program called Command.java that gives the following output: What if the number of String inputs is not fixed? How can we print them?? 2016 Winter
  • 19. For Quiz Question 1 You can use DrJava as well as Command Line Interface 2016 Winter
  • 20. Write the program ArrayTool described below. Test with several values for “cutOffValue” to ensure that your program works. 2016 Winter
  • 21. Write the program ArrayTool described below. Test with several values for “cutOffValue” to ensure that your program works. 2016 Winter