An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Today’s lecture Review of Chapter 1 Go over homework exercises for chapter 1.
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Chapter 2 Review Questions
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
CS 106 Introduction to Computer Science I 02 / 18 / 2008 Instructor: Michael Eckmann.
Shlomo Hershkop1 Introduction to java Class 1 Fall 2003 Shlomo Hershkop.
Java Syntax Primitive data types Operators Control statements.
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
From C++ to Java A whirlwind tour of Java for C++ programmers.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Arrays Chapter 8. What if we need to store test scores for all students in our class. We could store each test score as a unique variable: int score1.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Objects, Classes and Syntax Dr. Andrew Wallace PhD BEng(hons) EurIng
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Basic Java Syntax COMP 401, Spring 2014 Lecture 2 1/14/2014.
CSC1030 HANDS-ON INTRODUCTION TO JAVA Introductory Lab.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
1 More data types Character and String –Non-numeric variables –Examples: char orange; String something; –orange and something are variable names –Note.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
Chapter One Lesson Three DATA TYPES ©
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
CSCI S-1 Section 4. Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST.
Java Part I By Wen Fei, HAO. Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
Object Oriented Programming Lecture 2: BallWorld.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Review by Mr. Maasz, Summary of Chapter 2: Starting Out with Java.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Crash course in the Java Programming Language
Yanal Alahmad Java Workshop Yanal Alahmad
Lecture 2: Data Types, Variables, Operators, and Expressions
An Introduction to Java – Part I
Chapter 2.
Introduction to Programming in Java
Unit-2 Objects and Classes
null, true, and false are also reserved.
Computers & Programming Languages
Introduction to Java Programming
An Introduction to Java – Part I, language basics
Java so far Week 7.
Java Programming Review 1
Names of variables, functions, classes
Comparing Python and Java
Agenda Types and identifiers Practice Assignment Keywords in Java
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

An Introduction to Java – Part 1 Dylan Boltz

What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed to bridge the gap between digital consumer devices and computers  Syntax very similar to that of C++

Basic Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods }

Things to Remember About the Structure  Public classes are accessible from any class.  Classes, which are not declared public are accessible only within their package  Public methods may be called from any class.  Static methods do not operate on objects.  The keyword void indicates that the method does not return a value.  The array args of the main method stores command line arguments.

Operators  Arithmetic Operators: +, -, *, /, %  Relational Operators: ==, !=,, =  Logical Operators: &&, ||, !

Data Types  Integers – int, short, long, byte  Floating-Point Types – float, double  Character Type – char  Boolean Type – boolean (values: true, false)

Strings  Standard class in Java  ‘+’ used for string concatenation  Example:  String greeting = “hello”;  Member Functions:  int compareTo(String other)  boolean equals(Object other)  int length()

Variables  Variables need to be declared  Variables must be initialized before use  Examples:  int year = 2010;  System.out.println(year);  String greeting = “Hello”;  String name = “Bob”;  System.out.println(greeting + “ “ + name);

Conditional Statements  If/else statements similar to C++  Curly braces not required for enclosing a single instruction Example: If(…){ … }else{ … } Example: If(…) … else …

Loops  While Loops  Similar to C++  Example  while(…){  …  }  For Loops  Also similar to C++  Example  for(initialization; condition; update){  …  }

Arrays  Also similar to C++  Arrays are a standard class in Java  Selected Member Functions  static void sort(type [ ] a)  static int binarySearch(type [ ] a, type v)  static boolean equals(type [ ] a, Object other) Example: int[ ] numbers = new int[ 10 ]; for(int i = 0; i < numbers.length; i++) numbers[ i ] = i;

Resources  anguage_basics.pdf anguage_basics.pdf   java/data/basic_types/21integers.html java/data/basic_types/21integers.html  java/data/basic_types/22floatingpoint.html java/data/basic_types/22floatingpoint.html