Java Fundamentals MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.

Slides:



Advertisements
Similar presentations
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Advertisements

Shlomo Hershkop1 Introduction to java Class 1 Fall 2003 Shlomo Hershkop.
CMT Programming Software Applications
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
1 Data types, operations, and expressions Overview l Format of a Java Application l Primitive Data Types l Variable Declaration l Arithmetic Operations.
Computer Science A 2: 6/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Methods: a first introduction Two ways to make tea: 1: boil water; put teabag into cup;... etc : tell your younger brother: makeTea(1 milk, 0 sugar);
Hello, world! Dissect HelloWorld.java Compile it Run it.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Hello AP Computer Science!. What are some of the things that you have used computers for?
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
1 Course Lectures Available on line:
DAT602 Database Application Development Lecture 5 JAVA Review.
***** SWTJC STEM ***** Chapter 2-2 cg Identifiers - Naming Identifier, the name of a Java programming component. Identifier naming rules... Must.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation.
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.
Chapter 2: Java Fundamentals
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
Java Arrays and Methods MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Java Expressions MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Chapter 2 Variables.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
1 Chapter 2: Java Fundamentals cont’d Spring Lory Al Moakar.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
By Mr. Muhammad Pervez Akhtar
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Java: Variables and Methods By Joshua Li Created for the allAboutJavaClasses wikispace.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Java I/O Basics MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh Bajaj,
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
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.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Information and Computer Sciences University of Hawaii, Manoa
Chapter 2 Variables.
Chapter 2 Basic Computation
Crash course in the Java Programming Language
Console Output, Variables, Literals, and Introduction to Type
Variables and Primative Types
Lecture Note Set 1 Thursday 12-May-05
Programming Language Concepts (CIS 635)
Chapter 2.
An Introduction to Java – Part I, language basics
Chapter 2 Variables.
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
CSE 142, Spring 2012 Building Java Programs Chapter 1
In this class, we will cover:
Unit 3: Variables in Java
Chapter 2 Variables.
CSE 142, Winter 2014 Building Java Programs Chapter 1
JAVA. Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of platforms, such.
Presentation transcript:

Java Fundamentals MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh Bajaj, All rights reserved

Objectives Understand the building blocks of programs Learn the basic Java TM types Take another look at our first lab Let’s get started!

Building Blocks of Programming Data & Instructions are the 2 fundamental building blocks. Data: Types & Variables Instructions: Control structures & subroutines Data: A type is the set of possible values that a variable of that type can contain. E.g., what values can a variable of type int contain? A variable is a label or a name for a main memory location. Memory maps: Maps of the main memory of the process as it executes, showing the data being used by the process.

Building Blocks of Programming Instructions: Control structures & subroutines Control structures manage the “flow of control”. The basic structures are: branching (if, switch) and looping (for, while, do-while). Subroutines are used to chunk tasks. We divide the overall task our program needs to perform into chunks, and then label each chunk with the name of the subroutine. In Java, subroutines are called methods. In C/C++ they are called functions. In BASIC, they are called subroutines. In Pascal, they are called procedures and functions. It’s very important to plan the program so that it is broken into meaningful chunks. Rules of thumb for chunking: a) If we are typing the same code again and again, we should write it in a method, and then call the method by name in the program. b) If it helps us solve the overall problem by assuming a certain part is already taken care of in the method, without worrying about how, then that certain part can be coded as a subroutine or method and called in the program.

Basic Types in Java Java is strongly typed. Primitive Types: These are the building blocks for more complex types. TypeBit Size ValuesStandard boolean8true, false char16‘\u0000’ to ‘\uFFFF’ISO Unicode Char Set byte8-128 to short16-32,768 to +32,767 int32-2,147,483,648 to +2,147,483,647 long64-9,223,372,036,854,775,808 to + (that -1) float E+38 to + thatIEEE 754 floating point double E+308 to + that IEEE 754 floating point

Basic Types in Java The most common numerical types we will use are: int for integers, double for decimal points For char constants, put a single character in single quotes. The Unicode char set contains 65,536 characters, in other words all chars in all written languages. 255 chars in this scheme are ASCII. So we just put whatever character we want in single quotes, as a char constant. The following special character values can be used: ‘\b’backspace ‘\t’ tab ‘\n’linefeed ‘\r’carriage return \''double quote (a single quote will give us a single quote) \\backslash Note: ‘3’ is a char, 3 is a numeric literal, ‘a’ is a char, a is a variable name. “Akhilesh” is a String.

Basic Types in Java String: This is not a primitive type in Java. However, it is used so often, that we need to look at it right away. A String is a class in the standard Java library. A class is more complex than a type. We create variables of types But we create objects of classes. We create objects of class String, every time we need a String. Each object we create has a name, data (the actual string of characters) and certain operations (methods) that we can use on that object. String greeting = “Hello”; String emptyStr = “”; //an empty string System.out.println(greeting + ‘\n’); Prints out Hello and then a new line. List of useful methods for String class in our text book: \\bahweb\nfp\bajaja\MIS3023\Text\javanotes4.1\c2\s3.html

Basic Types in Java String: We do not need to understand how these object methods work. We use them as black boxes. A lot of the power of Java is the API (Application Programming Interface) which consists of a lot of classes that we can use, without really looking at the code that went into them. lists the current API for Java. Classes can have two types of methods in Java: a) A class can have static methods that are called by Classname.methodname(any parameters) b) A class can have non-static methods that need an object created first of that class, and then they can be used. The String methods we saw are non-static. println() is a static method called on class System.out without declaring an object of that class.

Revisiting our First Lab import java.io.*; public class HelloWorld { // A program to display the message // "Hello World!" on standard output public static void main(String[] args) { System.out.println("Hello World!"); } } // end of class HelloWorld Import hints to Java compiler where to look for classes we are using We write every file as a class. The file name we save it as MUST be the same as the class name with a.java extension. Each program has a main() method that is run first. In this example, that is the ONLY method. The println() method is a static method in the out class, which is a subclass of the System class.

Fun In Class Assignment Let us think about a car payment calculator program, to help a car dealership’s customers decide how much they can pay. What variables (data) do we need to solve the problem? What flow (process) do we need to solve the problem? Write a sketch of the program on paper.

We took a look at the basic building blocks of programming We learnt basic types and the String Class Chapter 2, section 2 in our book has more explanation: 1/c2/s2.html We began to understand classes and how they work CONCLUSION