Java for Android is specific

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

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Programming Languages and Paradigms The C Programming Language.
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
23-Apr-15 Abstract Data Types. 2 Data types I We type data--classify it into various categories-- such as int, boolean, String, Applet A data type represents.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
CS 106 Introduction to Computer Science I 02 / 18 / 2008 Instructor: Michael Eckmann.
Loops – While, Do, For Repetition Statements Introduction to Arrays
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Arrays, Conditionals & Loops in Java. Arrays in Java Arrays in Java, are a way to store collections of items into a single unit. The array has some number.
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
Java Tutorial Write Once, Run Anywhere. Java - General Java is: –platform independent programming language –similar to C++ in syntax –similar to Smalltalk.
 Java is:  platform independent programming language  similar to C++ in syntax  similar to Smalltalk in mental paradigm  Java has some interesting.
Java Basics Kris Secor Mobile Application Development.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
JavaServer Pages Syntax Harry Richard Erwin, PhD CSE301/CIT304.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
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.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Primitive data Week 3. Lecture outcomes Primitive data – integer – double – string – char – Float – Long – boolean Declaration Initialisation Assignments.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Introduction to Java Java Translation Program Structure
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Windows Programming Lecture 03. Pointers and Arrays.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Primitive data types Lecture 03. Review of Last Lecture Write a program that prints the multiplication table of 5. class MultiplicationTable { public.
(Java Looping and Conditional Statements). Flow of control Sequential Executes instructions in order Method Calls Transfer control to the methods, then.
Repetition Statements
Information and Computer Sciences University of Hawaii, Manoa
Java Programming Fifth Edition
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Java for Android is specific
A bit of C programming Lecture 3 Uli Raich.
Selection (also known as Branching) Jumail Bin Taliba by
Programming Languages and Paradigms
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Programming Paradigms
C Basics.
Java Programming: From Problem Analysis to Program Design, 4e
Engineering Innovation Center
Starting JavaProgramming
Java - Data Types, Variables, and Arrays
An Introduction to Java – Part I, language basics
An overview of Java, Data types and variables
Chapter 2: Basic Elements of Java
In this class, we will cover:
Introduction to Primitive Data types
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Sridhar Narayan Java Basics Sridhar Narayan
Java Programming Review 1
Arrays in Java.
In this class, we will cover:
Comparing Python and Java
CSC215 Lecture Control Flow.
Review of Java Fundamentals
Introduction to Primitive Data types
Presentation transcript:

Java for Android is specific The Java we'll need to learn first is: The core language Collections IO String handling We will not need to learn Servlets or Swing or a few other java concepts as this is about developing for android

Goals for an intro course Learn to write simple code Learn to understand complex code Understand and accept encapsulation and be able to use the android libraries Get experience at troubleshooting Get one app under our belts Have realistic expectations

Let’s look at the tools Java Docs Java Docs for Android Android Studio Genymotion

Basic Java Syntax

Primitive Types and Variables boolean, char, byte, short, int, long, float, double etc. These basic (or primitive) types are the only types that are not objects (due to performance issues). This means that you don’t use the new operator to create a primitive variable. Declaring primitive variables: float initVal; int retVal, index = 2; double gamma = 1.2, brightness boolean valueOk = false;

Initialization If no value is assigned prior to use, then the compiler will give an error Java sets primitive variables to zero or false in the case of a boolean variable All object references are initially set to null An array of anything is an object Set to null on declaration Elements to zero false or null on creation

Declarations int index = 1.2; // compiler error boolean retOk = 1; // compiler error double fiveFourths = 5 / 4; // no error! float ratio = 5.8f; // correct double fiveFourths = 5.0 / 4.0; // correct 1.2f is a float value accurate to 7 decimal places. 1.2 is a double value accurate to 15 decimal places.

Assignment int a = 1, b = 2, c = 5 a = b = c System.out.print( All Java assignments are right associative int a = 1, b = 2, c = 5 a = b = c System.out.print( “a= “ + a + “b= “ + b + “c= “ + c) What is the value of a, b & c Done right to left: a = (b = c);

Basic Mathematical Operators * / % + - are the mathematical operators * / % have a higher precedence than + or - double myVal = a + b % d – c * d / b; Is the same as: double myVal = (a + (b % d)) – ((c * d) / b);

Statements & Blocks A simple statement is a command terminated by a semi-colon: name = “Fred”; A block is a compound statement enclosed in curly brackets: { name1 = “Fred”; name2 = “Bill”; } Blocks may contain other blocks

Flow of Control Java executes one statement after the other in the order they are written Many Java statements are flow control statements: Alternation: if, if else, switch Looping: for, while, do while Escapes: break, continue, return