FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.
Email: Нажмите что бы посмотреть
Object is entity that has the following features:
Vehicle auto;
Vehicle moto = null;
Create objects auto and moto by new keyword.
auto = new Vehicle();
moto = new Vehicle();
GET & SET ATTRIBUTES
To get: variable = object.field;
To set: object.field = variable;
Every object has independent fields.
CALLING METHODS
NUMBER WRAPPERS
int x = 25;
Integer y = new Integer(33);
REASONS
Double Var = new Double (3.1415);
int i = Var.intValue();
Integer Var = new Integer (5);
int i = 3;
if(Var.compareTo(i)) System.out.println (“They are the same!”);
else System.out.println (“They are different!”);
STRING INTO INTEGER
static Integer decode(String s)
Decodes a string into an integer. Can accept string representations of decimal, octal, or hexadecimal numbers as input.
Integer iVar = Integer.decode(“3”);
static int parseInt(String s)
Returns an integer (decimal only).
int i = Integer.parseInt(“3”);
static int parseInt(String s, int radix)
Returns an integer, given a string representation of decimal, binary, octal, or hexadecimal (radix equals 10, 2, 8, or 16 respectively) numbers as input.
int i = Integer.parseInt(“3”,16);
static String toString(int i)
Returns a String object representing the specified integer.
String s1 = Integer.toString(25); //"25”
static String toBinaryString(int i)
public static String toOctalString(int i)
public static String toHexString(int i)
Returns a String object representing the specified integer in binary, octal or hexadecimal form.
String s1 = Integer.toBinaryString(12); //“1100”
EXERCISE
HOMEWORK