Class Library java.lang Package. Bok, Jong Soon

Similar documents

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Creating Strings. String Length

String. Other languages that implement strings as character arrays

Lab 14 & 15: String Handling

JAVA WRAPPER CLASSES

PIC 20A Number, Autoboxing, and Unboxing

Index COPYRIGHTED MATERIAL

Strings. Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects.

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

We now start exploring some key elements of the Java programming language and ways of performing I/O

A variable is a name for a location in memory A variable must be declared

Mathematics for Computer Graphics - Lecture 12

Chapter 10: Text Processing and More about Wrapper Classes

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

Introductory Mobile Application Development

CST242 Strings and Characters Page 1

C08c: A Few Classes in the Java Library (II)

Appendix 3. Description: Syntax: Parameters: Return Value: Example: Java - String charat() Method

String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016

Java Programming Lecture 10

TEXT-BASED APPLICATIONS

Chapter 4 Mathematical Functions, Characters, and Strings

String related classes

More on Strings. Lecture 10 CGS 3416 Fall October 13, 2015

MATHEMATICAL FUNCTIONS CHARACTERS, AND STRINGS. INTRODUCTION IB DP Computer science Standard Level ICS3U

Chapter 12 Strings and Characters. Dr. Hikmat Jaber

CS1150 Principles of Computer Science Math Functions, Characters and Strings (Part II)

Contents. Osp::Base::Object Osp::Base::String Osp::Base::Buffer Osp::Base::DateTime

Interaction with Android

STRINGS AND STRINGBUILDERS. Spring 2019

2. All the strings gets collected in a special memory are for Strings called " String constant pool".

Chapter 8 Strings. Chapter 8 Strings

SOFTWARE DEVELOPMENT 1. Strings and Enumerations 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)

5/23/2015. Core Java Syllabus. VikRam ShaRma

CSC Java Programming, Fall Java Data Types and Control Constructs

Tha Java Programming Language

Chapter 11 Object-Oriented Design Exception and binary I/O can be covered after Chapter 9

JAVA.LANG.INTEGER CLASS

Data Types and Variables

JAVA NUMBERS, CHARS AND STRINGS

Overloaded Methods. Sending Messages. Overloaded Constructors. Sending Parameters

CS 1301 Ch 8, Part A

Darshan Institute of Engineering & Technology for Diploma Studies Unit 2

Java s String Class. in simplest form, just quoted text. used as parameters to. "This is a string" "So is this" "hi"

Unit 3 INFORMATION HIDING & REUSABILITY. Interface:-Multiple Inheritance in Java-Extending interface, Wrapper Class, Auto Boxing

ITI Introduction to Computing II

Eng. Mohammed Abdualal

USING LIBRARY CLASSES

ITI Introduction to Computing II

APPENDIX A: SUMMARY OF IMPORTANT JAVA FEATURES

Lesson:9 Working with Array and String

ECE 122. Engineering Problem Solving with Java

Chapter 9 Abstract Classes and Interfaces

CSB541 Network Programming 網路程式設計. Ch.2 Streams 吳俊興國立高雄大學資訊工程學系

J.43 The length field of an array object makes the length of the array available. J.44 ARRAYS

15CS45 : OBJECT ORIENTED CONCEPTS

Java Programming with Eclipse

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

Java 1.8 Programming

"Hello" " This " + "is String " + "concatenation"

Programming Techniques

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV

Lecture Notes K.Yellaswamy Assistant Professor K L University

Object-Oriented Programming

CHAPTER 4 MATHEMATICAL FUNCTIONS, CHARACTERS, STRINGS

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing

Building Strings and Exploring String Class:

CHAPTER 6 MOST COMMONLY USED LIBRARIES

Review. Single Pixel Filters. Spatial Filters. Image Processing Applications. Thresholding Posterize Histogram Equalization Negative Sepia Grayscale

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Polymorphism. return a.doublevalue() + b.doublevalue();

CST141 Thinking in Objects Page 1

From C++ to Java. Duke CPS

ECS-503 Object Oriented Techniques

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Final Examination

Strings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Points To Remember for SCJP

Introduction to Programming Using Java (98-388)

Brief Summary of Java

IntWritable w1 = new IntWritable(163); IntWritable w2 = new IntWritable(67); assertthat(comparator.compare(w1, w2), greaterthan(0));

Intro to Strings. Lecture 7 COP 3252 Summer May 23, 2017

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Java Language Features

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017

Java Classes: Math, Integer A C S L E C T U R E 8

Formatting Output & Enumerated Types & Wrapper Classes

More on variables and methods

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness.

INHERITANCE. Spring 2019

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Intro to Strings. Lecture 7 CGS 3416 Spring February 13, Lecture 7 CGS 3416 Spring 2017 Intro to Strings February 13, / 16

Chettinad College of Engineering & Technology Department of Information Technology Internal Examination II (Answer Key)

+ Inheritance. n Superclass (base class) higher in the hierarchy. n Subclass (child class) lower in the hierarchy

STUDENT LESSON A10 The String Class

Strings, StringBuffer, StringBuilder

Transcription:

Class Library java.lang Package Bok, Jong Soon javaexpert@nate.com www.javaexpert.co.kr

Object class Is the root of the class hierarchy. Every class has Object as a superclass. If no inheritance is specified when a class is defined, the superclass of the class is Object by default.

Object class clone() Performs a "shallow copy" of this object, not a "deep copy" operation.

Object class clone()(cont.) To doing deep copy using method s override.

Object class equals()

Object class finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of System resources or to perform other cleanup. Is never invoked more than once by a Java virtual machine.

Object class finalize()(cont.)

Object class getclass() Returns the runtime class of an object.

Object class tostring()

Wrapper Classes Look at primitive data elements as objects. Primitive Data Type Wrapper Class Methods to get primitive values boolean Boolean booleanvalue() byte Byte charvalue() char Character bytevalue() short Short shortvalue() int Integer intvalue() long Long longvalue() float Float floatvalue() double Double doublevalue()

Wrapper Classes (Cont.)

Boolean Class Wraps a value of the primitive type boolean in an object.

Numeric Wrapper Classes Each wrapper class overrides the tostring(), equals(), and hashcode(). All the numeric wrapper classes and the Character class implement the Comparable interface the compareto() is implemented in these classes.

Numeric Wrapper Classes

Numeric Wrapper Classes Common Constructors Datatype (datatype value) Datatype (String s) throws NumberFormatException Common Fields static datatype MAX_VALUE static datatype MIN_VALUE

Numeric Wrapper Classes (Cont.) Common Methods datatype datatypevalue () datatype compareto (Datatype anotherdatatype) static datatype parsedatatype (String s) boolean equals (Object obj) String tostring() static Datatype valueof (String s)

Numeric Wrapper Classes (Cont.) Etc methods static String tobinarystring (int i) static String tohexstring (int i) static String tooctalstring (int i)

Character Class Wraps a value of the primitive type char in an object. Character information is based on the Unicode Standard, version 4.0

Character Class Wraps a value of the primitive type char in an object. Character information is based on the Unicode Standard, version 4.0 Character (char value) static boolean isxxx (char ch) static boolean isxxx (int codepoint)

Autoboxing and Autounboxing

Math Class Contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. Is final class. So, Cannot inherit. All field is final fields. So, Cannot assign literal. All method is final method. So, Cannot override it.

Math class (Cont.) static type abs (type value) static type max (type a, type b) static type min (type a, type b) static double pow (double a, double b) static double sqrt (double a) static double random () static double ceil (double a) static double floor (double a) static int round (float a) static long round (double a)

String class Represents character strings. All string literals are implemented as instances of this class. Strings are constant. Their values cannot be changed after they are created. Case mapping relies heavily on the information provided by the Unicode Consortium's Unicode 4.0 specification.

String class (Cont.) Provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuffer class and its append method.

String class (Cont.) String (byte [] bytes) String (byte [] bytes, int offset, int length) String (byte [] bytes, int offset, int length, String charsetname) String (byte [] bytes, String charsetname) String (char [] value) String (char [] value, int offset, int count) String (String original) String (StringBuffer buffer)

String class (Cont.) char charat (int index) int compareto (String anotherstring) int comparetoignorecase (String str) String concat (String str) static String copyvalueof (char [] data) static String copyvalueof (char [] data, int offset, int count) boolean endswith (String suffix) boolean equals (Object anobject) boolean equalsignorecase (String anotherstring)

String class (Cont.) byte [] getbytes () byte [] getbytes (String charsetname) void getchars (int srcbegin, int srcend, char [] dst, int dstbegin) int hashcode () int indexof (int ch) int indexof (int ch, int fromindex) int indexof (String str) int indexof (String str, int fromindex)

String class (Cont.) int lastindexof (int ch) int lastindexof (String str) int length () boolean matches (String regex) boolean regionmatches (boolean ignorecase, int toffset, String other, int ooffset, int len) String replace (char oldchar, char newchar) String replaceall (String regex, String replacement) boolean startswith (String prefix)

String class (Cont.) String substring (int beginindex) String substring (int beginindex, int endindex) char [] tochararray () String tolowercase () String tostring() String touppercase () String trim () static String valueof (type t)

Unicode Character Set(UCS)* Charset US-ASCII ISO-8859-1 UTF-8 UTF-16BE UTF-16LE UTF-16 Description Seven-bit ASCII, ISO646-US, the Basic Latin block of the Unicode character set ISO Latin Alphabet No. 1, ISO-LATIN-1 Eight-bit UCS Transformation Format Sixteen-bit UCS Transformation Format, big-endian byte order Sixteen-bit UCS Transformation Format, little-endian byte order Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark EUC**-KR Eight-bit, Unified Hangeul Code ( 통합완성형 ) KS C 5601 MS949*** KS_C_5601-1987, KSC_5601, KSC5601, KS X 1001, Korean Graphic Character Set for Information Interchange Code page 949, Windows Codepage 949, Microsoft s implementation that appears similar to EUC-KR * java.nio.charset.charset * Extended Unix Code (EUC) is a multibyte character encoding system used primarily for Korean, Japanese and simplified Chinese. ** http://msdn.microsoft.com/ko-kr/goglobal/cc305154

String class (Cont.)

String class (Cont.)

String class (Cont.)

String class (Cont.)

String class (Cont.)

String class (Cont.)

String class (Cont.)

StringBuffer class Is final class. A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can be modified. String buffers are used by the compiler to implement the binary string concatenation operator +. Every string buffer has a capacity. As long as the length of the character sequence contained in the string buffer does not exceed the capacity, it is not necessary to allocate a new internal buffer array. If the internal buffer overflows, it is automatically made larger.

StringBuffer class (Cont.) StringBuffer (int length) StringBuffer (String str) StringBuffer append (type t) int capacity () StringBuffer delete (int start, int end) StringBuffer deletecharat (int index) void getchars (int srcbegin, int srcend, char [] dst, int dstbegin) int indexof(string str)

StringBuffer class (Cont.) StringBuffer insert (int offset, type t) int lastindexof (String str) int length () StringBuffer replace (int start, int end, String str) StringBuffer reverse () void setcharat (int index, char ch) void setlength (int newlength) String substring (int start) String substring (int start, int end)

StringBuffer class (Cont.)

StringBuffer class (Cont.)

StringBuffer class (Cont.)

System class Is final class. Contains several useful class fields and methods. It cannot be instantiated. Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined "properties static PrintStream err : Standard error output static InputStream in : Standard input static PrintStream out : Standard output

System class (Cont.) static void arraycopy (Object src, int srcpos, Object dest, int destpos, int length) static long currenttimemillis () static void exit (int status) static void gc () static Properties getproperties () static String getproperty (String key) static String getproperty (String key, String def)

System class (Cont.)

System class (Cont.)

Runtime class Every Java application has a single instance of class Runtime. Allows the application to interface with the environment in which the application is running. The current runtime can be obtained from the getruntime() method. An application cannot create its own instance of this class.

Runtime class (Cont.)

Runtime class (Cont.)