SlideShare une entreprise Scribd logo
1  sur  23
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

Contenu connexe

Tendances

Tendances (20)

Swing
SwingSwing
Swing
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Java swing
Java swingJava swing
Java swing
 
java Features
java Featuresjava Features
java Features
 
Java buzzwords
Java buzzwordsJava buzzwords
Java buzzwords
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | Edureka
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
 
Jdbc in servlets
Jdbc in servletsJdbc in servlets
Jdbc in servlets
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
DESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy PatternsDESIGN PATTERNS: Strategy Patterns
DESIGN PATTERNS: Strategy Patterns
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 

En vedette

Java Tutorial Lab 7
Java Tutorial Lab 7Java Tutorial Lab 7
Java Tutorial Lab 7Berk Soysal
 
Java Tutorial Lab 3
Java Tutorial Lab 3Java Tutorial Lab 3
Java Tutorial Lab 3Berk Soysal
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2Berk Soysal
 
Java Tutorial Lab 4
Java Tutorial Lab 4Java Tutorial Lab 4
Java Tutorial Lab 4Berk Soysal
 
Java Tutorial Lab 8
Java Tutorial Lab 8Java Tutorial Lab 8
Java Tutorial Lab 8Berk Soysal
 
Self Evaluation Test
Self Evaluation Test Self Evaluation Test
Self Evaluation Test Berk Soysal
 
Java Tutorial Lab 9
Java Tutorial Lab 9Java Tutorial Lab 9
Java Tutorial Lab 9Berk Soysal
 
Java Tutorial Lab 6
Java Tutorial Lab 6Java Tutorial Lab 6
Java Tutorial Lab 6Berk Soysal
 
Java Tutorial Lab 5
Java Tutorial Lab 5Java Tutorial Lab 5
Java Tutorial Lab 5Berk Soysal
 
Behavior Management Part 2
Behavior Management Part 2Behavior Management Part 2
Behavior Management Part 2MaryAlyssaBotin
 
Java tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry LevelJava tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry LevelRamrao Desai
 
Chapter12 - Designing System Interfaces, Controls and Security(Demo Presentat...
Chapter12 - Designing System Interfaces, Controls and Security(Demo Presentat...Chapter12 - Designing System Interfaces, Controls and Security(Demo Presentat...
Chapter12 - Designing System Interfaces, Controls and Security(Demo Presentat...John Ely Masculino
 

En vedette (13)

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

Similaire à Java Tutorial Lab 1

Similaire à Java Tutorial Lab 1 (20)

OOP with Java
OOP with JavaOOP with Java
OOP with Java
 
Java Programming Fundamentals
Java Programming Fundamentals Java Programming Fundamentals
Java Programming Fundamentals
 
Java introduction
Java introductionJava introduction
Java introduction
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
01slide
01slide01slide
01slide
 
01slide
01slide01slide
01slide
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
Java
JavaJava
Java
 
Java programming - solving problems with software
Java programming - solving problems with softwareJava programming - solving problems with software
Java programming - solving problems with software
 
Comp102 lec 3
Comp102   lec 3Comp102   lec 3
Comp102 lec 3
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
perl-java
perl-javaperl-java
perl-java
 
perl-java
perl-javaperl-java
perl-java
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Chapter 1.3
Chapter 1.3Chapter 1.3
Chapter 1.3
 
GETTING STARTED WITH JAVA(beginner)
GETTING STARTED WITH JAVA(beginner)GETTING STARTED WITH JAVA(beginner)
GETTING STARTED WITH JAVA(beginner)
 

Dernier

Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainAbdul Ahad
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotEdgard Alejos
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 

Dernier (20)

Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software Domain
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform Copilot
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 

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