◆ Types : a set of values and the operations that can be carried out on the value
- Java has separate types for integers and floating-point numbers
- A value such as 13 or 1.3 that occurs in a Java program is called a number literal
◆ Number Types
- A type defines a set of values and the operations that can be carried out on the values
- Number types are primitive types (most basic, can stand alone / ※ it's NOT object)
- can be combined by arithmetic operators (+,-,*...)
◆ Variables
- Purpose : store a value that you want to see at a later time
- variable has a type, a name and a value
EX) int width = 13;
type name value
※NAME※
- Must be a char
- Cannot be a number
- Cannot use symbol
- _ is allowed but not advisible
- No reserved word
- variables can be used in place if the values that they store
- not match the type -> error to store a value
◆ Identifier : name of a variable, method, or class
- Rules for identifier in Java
* OK : letters, digits, _ (underscore), $
* NO : starting with a digit // other symbol (?,%...) // spaces // reserved word
- By convention...
* variable names start with a lower case
* class names start wit/ a upper case
- DO NOT use $ : it is intended for names that are automatically generated by tools
◆ The Assignment Operator, = : used to change the value
◆ Uninitialized Value
- use a variable that has never had a value assigned to it is an ERROR
-> assign a value to the variable before you use it
-> Even better, initialize the variable when you declare it
◆ Objects and Classes
- Object : entity that you can manipulate in your programs (by calling method)
- Each objects belongs to a class
◆ Methods
- Method : Sequence of instructions that accesses the data of object
* you manipulate objects by calling its methods
- Class : declares the methods that you can apply to its objects
* Class determines legal methods
- Public Interface : specifies what you can do with the objects of a class
◆ Overloaded Method : when a class declares two methods with the same name, but different parameters
◆ String Methods
- length : counts the number of characters in a string
- toUpperCase : creates another String objects that contains the characters of original string, with lowercase letters converted to uppercase
- When applying a method to an object, make sure method is defined in the appropriate class
◆ Parameters : an input to a method
- Implicit parameter : the object on which a method is invoked
- Explicit parameter : all parameters except the implicit
- Not all methods have explicit parameter
◆ Constructing Objects
- Construction : the process of creating a new object
ex. Rectangle box = new Rectangle(5,10,20,30) ~ 5,10,20,30 is construction parameters
◆ Accessor and Mutator Methods
- Accessor method : does not change the state of its implicit parameter
- Mutator method : changes the state of its implicit parameter
◆ The API Documentation
- API : Application Programming Interface
- API documentation : lists classes and methods in the Java library.
-http://java.sun.com/javase/7/docs/api/index.html
◆ Packages
- Package : a collection of classes with a related purpose
- Import library classes by spectifying the package and class name
◆ Object Reference : describes the location of an object
- The new operator returns a reference to a new object
- Multiple object variables can refer to the same object
Rectangle box = new Rectangle(5,10,20,30);
Rectangle box2 = box;
- Primitive type variables ≠ object variables
'Computers > Language java' 카테고리의 다른 글
week4. Fundamental Data Types (0) | 2011.04.10 |
---|---|
week3. Implementing Classes (Basic Java Concept part2) (0) | 2011.04.10 |
week1. Introduction (0) | 2011.04.09 |
eclipse 단축키 (0) | 2011.04.08 |
Java api 원문 링크 (0) | 2011.04.07 |