Week1 Using the Library (the Java API) Classes are grouped together in packages –To use a class you have to know which package it is in –Every package.

Slides:



Advertisements
Similar presentations
More Sophisticated Behaviour 1 Using library classes to implement more advanced functionality.
Advertisements

Importing methods in the Java library. Previously discussed Method = a collection of statements that performs a complex (useful) task A method is identified.
ECE122 L4: Creating Objects February 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 4 Creating and Using Objects.
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
Using the Java API
Java Library Java provides a huge library or collection of useful programs A gold mine of well-tested code that can save you countless hours of development.
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
More sophisticated behavior Using library classes to implement some more advanced functionality 4.0.
Chapter 2 storing numbers and creating objects Pages in Horstmann.
29-Jun-15 Using the Java API
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
Program Design Divide and Conquer –Divide the program into separate tasks Functional Decomposition Top-Down Design –Divide an overall problem into discrete.
More sophisticated behavior Using library classes to implement some more advanced functionality 3.0.
Programming with Collections Grouping & Looping - Collections and Iteration Week 7.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
References, Aliases, Garbage Collection and Packages Packages and Importing Classes Reading for this Lecture: L&L, Familiarize yourself with.
More sophisticated behavior Using library classes to implement some more advanced functionality.
JAVA LIBRARY CLASSES CITS Main concepts to be covered Using library classes: String, Math, Color Reading documentation Java 7 API is available.
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
Java Programming, Second Edition Chapter Four Advanced Object Concepts.
University of Limerick1 Work with API’s. University of Limerick2 Learning OO programming u Learning a programming language can be broadly split into two.
Week71 APCS-AB: Java Control Structures October 17, 2005.
Chapter 2: Objects and Primitive Data Classes and Objects String, Random, Math, NumberFormat, DecimalFormat and Wrapper Classes.
Java Packages and Libraries M Taimoor Khan
The Scala API Application Programmer’s Interface.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
More sophisticated behavior Using library classes to implement some more advanced functionality 5.0.
10-Nov-15 Java Object Oriented Programming What is it?
1 JAVA API & Packages Starring: Java Documentation Co-Starring: BlueJ IDE.
Class Libraries Chapter 1 1 Source Intro to Java Programming Y. Daniel Liang.
Using methods in the Java library. Previously discussed Method = a collection of statements that performs a complex (useful) task A method is identified.
School of Computer Science & Information Technology G6DICP - Lecture 14 Class Libraries.
Chapter 3 Introduction To Java. OBJECTIVES Packages & Libraries Statements Comments Bytecode, compiler, interpreter Outputting print() & println() Formatting.
CSS446 Spring 2014 Nan Wang.  A Java program consists of a collection of classes.  Package is a set of related classes. 2.
Application Programming Interfaces. Java comes with a bunch of classes that are already written. Java comes with a bunch of classes that are already written.
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
Modularity Computer Science 3. What is Modularity? Computer systems are organized into components called modules. The extent to which this is done is.
MCQ Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 (index 2) for the first time? a)recVehicles.set(3,
1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to.
Programming in Java (COP 2250) Lecture 7 Chengyong Yang Fall, 2005.
Computer Science 112 Fundamentals of Programming II.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Collections and Iteration Week 13.  Collections  ArrayList objects  Using loops with collections Collections and Iteration CONCEPTS COVERED THIS WEEK.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Java API Course Lecture Slides 7 June 2010 “ And you guys were putting.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
1 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used as a type to declare an object reference.
BlueJ Chapter 5 More sophisticated behavior: Library classes and documentation.
CSC 222: Object-Oriented Programming
More Sophisticated Behavior
Lecture 3 Linear Search and Binary Search ArrayLists
Classes, Libraries & Packages
Switch, Rounding Errors, Libraries
More sophisticated behavior
MSIS 655 Advanced Business Applications Programming
Using the Java Library API
Creating Objects A variable holds either a primitive value or a reference to an object A class name can be used as a type to declare an object reference.
Applying OO Concepts Using Java
Building a program (Java libraries) - an example
Review: libraries and packages
Using java libraries CGS3416 spring 2019.
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Chap 1. Getting Started Objectives
CMPE212 – Reminders Assignment 2 due today, 7pm.
Chap 4. Programming Fundamentals
Presentation transcript:

Week1 Using the Library (the Java API) Classes are grouped together in packages –To use a class you have to know which package it is in –Every package has a name (ArrayList is in the package java.util – which has a lot of utility classes) You have to use the full name of the class you will use in your code –import java.util.ArrayList; //now you can use it –java.util.ArrayList myList; //can use the full name as the datatype You’ve already used classes from the java.lang package… –System and Math are both classes –java.lang classes are sort of pre-imported (because they are so fundamental)

Week2 import The packages organize the classes to make them easier to find Can import complete packages with: –import package-name.*; –Ex: import java.util.*; //everything in util package Or can import just the class you will be using –import java.util.Random; –This way clearly shows which classes are used in the code (which makes it easier to document) java.lang classes are used so frequently, they are automatically imported

Week3 Java API It is essential for a good Java programmer to be able to work with the Java library and to make informed choices about which classes to use –Quickly enables you to perform many tasks more easily than you would otherwise have been able to do Know some of the most important classes from the library by name and how to find out about other classes and look up details

Week4 Reading the API Let’s look at the String class and some other classes –What is the structure of the class documentation? –Which sections are common to all class descriptions? What is their purpose? –Look up the startsWith method – what does it do? –Is there a method that tests whether a string ends with a certain suffix? –Is there a method that returns the number of characters in the string?