Java TA Session 1. Software Java Runtime Environment (JRE) java.exe Java Development Kit (JDK) java.exe, javac.exe Version 1.6 = Version 6, Version 1.7.

Slides:



Advertisements
Similar presentations
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Advertisements

How to Create a Java program CS115 Fall George Koutsogiannakis.
Introduction to Java ISYS 350. A Brief History Sun Microsystems released this language in 1996 – Versions: 1.0 – 1.6 Java Development Kit, JDK – Standard.
Unit2: Object-oriented programming Getting started with Java Jin Sa.
Tutorial 1 Introduction to Java Programming Bo Chen Department of Computer Science.
Update the PATH variable Trying to run the command: “javac Ex1.java” you’ve may encountered the error: “javac is not recognized as internal or external.
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
The switch statement: an N-way selection statement.
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
LAB 10.
Computer Programming Lab(4).
The for-statement. Different loop-statements in Java Java provides 3 types of loop-statements: 1. The for-statement 2. The while-statement 3. The do-while-statement.
Shorthand operators.
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
1 Introduction to Java Brief history of Java Sample Java Program Compiling & Executing Reading: => Section 1.1.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
1 Chapter 8 Multi-Dimensional Arrays. 2 1-Dimentional and 2-Dimentional Arrays In the previous chapter we used 1-dimensional arrays to model linear collections.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
Assignment statements using the same variable in LHS and RHS.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
Mixing integer and floating point numbers in an arithmetic operation.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Reading input from the console input. Java's console input The console is the terminal window that is running the Java program I.e., that's the terminal.
introductory lecture on java programming
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Method OverloadingtMyn1 Method overloading Methods of the same name can be declared in the same class, as long as they have different sets of parameters.
Classes - Intermediate
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
1 Simple Input Interactive Input - The Class Scanner n Command-Line Arguments.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
박 유 진.  IDE(Integrate Development Environment)  ECLIPSE Consortium  IBM, RedHat, METANT, QNX Software System etc…  Open Source Platform  Based JAVA.
Intro to Programming STARS College of Communication and Information Florida State University Written by: Hannah Brock Alissa Ovalle Nicolaus Lopez Martin.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
L AB #3. System.out.println(“if you have” +eggPerBasket + “egg per basket and” + numberOfBaskets +”baskets, then the total number off eggs is“+totalEggs);
Variable scope. Variable Scope Variables do not live forever. Failing to take that into account leads to problems. Let's look at an example. Let's write.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
Introduction of Java Fikri Fadlillah, S.T.
Chapter 2 Clarifications
Intro to ETEC Java.
Exercise 1- I/O Write a Java program to input a value for mile and convert it to kilogram. 1 mile = 1.6 kg. import java.util.Scanner; public class MileToKg.
Department of Computer Science
Software Development Packages
Compiling and Running a Java Program
Chapter 2 Elementary Programming
Maha AlSaif Maryam AlQattan
Programming without BlueJ Week 12
Repetition.
TK1114 Computer Programming
Comp Sci 200 Programming I Jim Williams, PhD.
CS Programming I Jim Williams, PhD.
Something about Java Introduction to Problem Solving and Programming 1.
While Statement.
CSE 1020:Programming by Delegation
class PrintOnetoTen { public static void main(String args[]) {
Differences between Java and JavaScript
Week 4 Lecture-2 Chapter 6 (Methods).
CS Week 2 Jim Williams, PhD.
CS Programming I Jim Williams, PhD.
6.2 for Loops Example: for ( int i = 1; i
Consider the following code:
Review of Previous Lesson
CS Programming I Jim Williams, PhD.
Presentation transcript:

Java TA Session 1

Software Java Runtime Environment (JRE) java.exe Java Development Kit (JDK) java.exe, javac.exe Version 1.6 = Version 6, Version 1.7 = Version 7 Edit System Variables: JAVA_HOME=C:\Program Files\Java\jdk1.6.0_32 PATH=[…];C:\Program Files\Java\jdk1.6.0_32\bin Editor: Notepad++, gedit

Java Startup Open Test.java Run javac: C:\Users\user\Documents>javac Test.java Run java: C:\Users\user\Documents>java Test Salam class Test { public static void main(String[] args) { System.out.println("Salam"); }

Errors C:\Users\user\Documents>javac Add1.java Add1.java:3: cannot find symbol symbol : class Scanner location: class Add1 Scanner s = new Scanner(System.in); ^ Add1.java:3: cannot find symbol symbol : class Scanner location: class Add1 Scanner s = new Scanner(System.in); ^ 2 errors

Add Import statement import java.util.Scanner; class Add1 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int a = s.nextInt(), b = s.nextInt(); int c = a+b; System.out.println("Sum is " + c); }

What to Import? You can read the Java API Specification at: Use search engines to find what you need: For example you can use the following query to search for “scanner” in the Java 6 API, using google: scanner site:docs.oracle.com/javase/6/docs/api/

Functions Use functions declared as public and static: public static int sum(int x, int y) Rewriting the previous code with a function: import java.util.Scanner; class Add1 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int a = s.nextInt(); int b = s.nextInt(); int c = sum(a, b); System.out.println("Sum is " + c); } public static int sum(int x, int y) { return x+y; }