CSS446 Spring 2014 Nan Wang.  A Java program consists of a collection of classes.  Package is a set of related classes. 2.

Slides:



Advertisements
Similar presentations
Coding Standards for Java An Introduction. Why Coding Standards are Important? Coding Standards lead to greater consistency within your code and the code.
Advertisements

PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
Chapter 7 Designing Classes Goals  To learn how to choose appropriate classes to implement  To understand the concepts of cohesion and coupling  To.
Objectives Learn about objects and reference variables Explore how to use predefined methods in a program.
COMS W1004 Introduction to Computer Science June 3, 2009.
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
Unit2: Object-oriented programming Getting started with Java Jin Sa.
***** SWTJC STEM ***** Chapter 3-1 cg 36 Java Class Libraries & API’s A class library is a set of classes that supports the development of programs. Java.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Packages.
 2005 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
1 Lecture 2: Object Oriented Programming in Java.
Packages. Package A package is a set of related classes Syntax to put a class into a package: package ; public class { …} Two rules:  A package declaration.
Simple Programs from Chapter 2 Putting the Building Blocks All Together (corresponds with Chapter 2)
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
Object Oriented Programming in Java Habib Rostami Lecture 5.
Ordered Lists By Brian Christian. Ordered List Tags You use this tag when you want to start an ordered list. Each list item you write need to start with.
Sahar Mosleh California State University San MarcosPage 1 System.out.println for console output System.out is an object that is part of the Java language.
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.
Lecture 2: Classes and Objects, using Scanner and String.
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
Static. Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. A static method does not operate on an object double dY.
Packages. Package 1.Avoid naming conflicts. Put classes into packages so that they can be referenced through package names. 2.Distribute software conveniently.
Assignment statements using the same variable in LHS and RHS.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
1 JAVA API & Packages Starring: Java Documentation Co-Starring: BlueJ IDE.
Using methods in the Java library. Previously discussed Method = a collection of statements that performs a complex (useful) task A method is identified.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. A class represents a single concept from the problem domain, or a.
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.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
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.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Packages. Access Specifications Public Available anywhere (public keyword) Only one public class per file allowed Protected Available in subclasses, and.
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
CSI 3125, Preliminaries, page 1 Packages. CSI 3125, Preliminaries, page 2 Packages Packages are containers for classes Collection of classes Packages.
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
CSC Java Programming, Spring, 2010 Week 2: Java Data Types, Control Constructs, and their C++ counterparts.
UNIT-3 Interfaces & Packages. What is an Interface? An interface is similar to an abstract class with the following exceptions: All methods defined in.
Week 13 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Dale Roberts Introduction to Java - Input, Program Control and Instantiation Dale Roberts, Lecturer Computer Science, IUPUI
Chapter 2 Console Input and Output Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Slides prepared by Rose Williams, Binghamton University Console Input and Output.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
Console Input and Output JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Java Packages - allow you to group classes as a collection Standard Java library has packages: java.lang and java.util … Also hierarchical: java and javax.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Software Development Packages
Letters.
Java Basics Packages.
Switch, Rounding Errors, Libraries
Data types, Expressions and assignment, Input from User
Something about Java Introduction to Problem Solving and Programming 1.
Java Packages B.Ramamurthy 11/11/2018 B.Ramamurthy.
Unit-2 Objects and Classes
Unit-1 Introduction to Java
Introduction to Computer Science and Object-Oriented Programming
Put the dots on the shift keys.
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
Building a program (Java libraries) - an example
Joel Adams and Jeremy Frens Calvin College
Using java libraries CGS3416 spring 2019.
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Interfaces,Packages and Threads
Presentation transcript:

CSS446 Spring 2014 Nan Wang

 A Java program consists of a collection of classes.  Package is a set of related classes. 2

 To put one of your classes in a package, you must place a line ◦ package packageName; as the first instruction in the source file containing the class.  If you did not include any package statement at the top of your source file, its classes are placed in the default package. 3

 If you want to use a class from a package, you can refer to it by its full name (package name plus class name).  Import java.util.Scanner; ◦ Import all classes from a package  Import java.util.*;  java.util.Scanner in=new java.util.Scanner(System.in);  Scanner in=new Scanner(System.in);  No need to import the classes in the java.lang package containing the most basic Java classes, such as Math and Object.  No need to import other classes in the same package. 4

 Use a domain name in reverse to construct an unambiguous package name. 5

 The path of a class file must match its package name.  the source files for classes in the package com.horstmann.bigjava 6

 java.lang.System.out.println(x);  Coding style ◦ If class names always start with an uppercase letter, and variable, method, and package names always start with a lower-case letter 7