Nội dung text 7_Java Support API.pdf
Chapter 7 Strings, Wrapper Classes Issue No./ Date : 01 / August. 06, 2023 Revision No. & Date : 00 / August. 06, 2023 Copyright © 2023, SEED Infotech Ltd. Pune, India. All rights reserved.
Content Structure ▪ Strings in Java ▪ Implement toString method and demonstrate its use ▪ Wrapper classes
String class ▪ Java library contains a predefined class called as String. ▪ The String type is not a primitive type. ▪ But in certain cases Java treats it like one. ▪ The ability to declare String literals instead of using new to instantiate a copy of the class String s=“seed”; ▪ String is a ‘First class object’.
String class ▪ String class represents an ‘immutable' string. ▪ i.e. Once an instance is created, the string it contains can not be changed. ▪ To change the String referenced by a String variable, you throw away the old string & replace it with the modified one(which in effect is a new String). “Hello” “Bye” s Old String New String