Deadlines - PowerPoint PPT Presentation

1 / 3
About This Presentation
Title:

Deadlines

Description:

The class defines how to construct an instance and also what methods all instances respond to ... how do I construct an instance of the class (the constructor) ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 4
Provided by: Steve57
Category:

less

Transcript and Presenter's Notes

Title: Deadlines


1
01-11
  • Deadlines
  • Assignment 1 due today
  • Assignment 2 on the web now, due 1/18
  • Last time
  • OOP terminology
  • The System class and interface to the operating
    system
  • User input and the Scanner class
  • This time
  • Quick review of OOP
  • Quick review of the Scanner class
  • Program to prompt for a name and say hello to it
  • Input from files
  • Command-line arguments
  • The String class

2
From Last Time
  • The main concepts in OOP
  • Classes represent abstract collections of
    individuals (instances or objects)
  • The class defines how to construct an instance
    and also what methods all instances respond to
  • Objects (class instances) denote nouns ("an
    employee") and methods denote verbs ("return
    salary")
  • When talking about an object you need to know its
    class, aka its data type (e.g. number, String,
    Scanner, PrintStream, System)
  • When talking about a method you need to know its
    signature (its name, number and types of
    arguments, and what information it returns)
  • Things to ask when learning about a new class
  • how do I make the class available to my program?
  • how do I construct an instance of the class (the
    constructor)?
  • what methods can I then call on instances I
    construct?

3
Last Time (cont.)
  • The Scanner class
  • not a system-defined class (in version 1.4.2) so
    we have to make the Scanner.class file available
    to the Java compiler and Java runtime environment
  • one way to do so is by putting Scanner.class in
    the working directory
  • there is no such thing as a "Scanner literal" so
    we have to call the constructor explicitly
  • Scanner s new Scanner(System.in)
  • after we have an instance, the first method we
    learned about was nextLine()
  • no arguments
  • returns a String, which is the next line
    available from its input source. Technically
    this is the sequence of characters up to, but not
    including, the next newline character
Write a Comment
User Comments (0)
About PowerShow.com