KEMBAR78
Chapter 12 Notes | PDF | Data Type | Programming Paradigms
0% found this document useful (0 votes)
4 views19 pages

Chapter 12 Notes

Chapter 12 discusses library classes in programming, focusing on the concept of data types, including primitive, composite, and user-defined types. It explains object creation using the 'new' operator, accessing member variables and methods, and introduces wrapper classes for converting primitive types to objects. Additionally, it covers auto boxing, auto unboxing, parsing strings to numeric values, and character checking methods.

Uploaded by

Bk Siri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views19 pages

Chapter 12 Notes

Chapter 12 discusses library classes in programming, focusing on the concept of data types, including primitive, composite, and user-defined types. It explains object creation using the 'new' operator, accessing member variables and methods, and introduces wrapper classes for converting primitive types to objects. Additionally, it covers auto boxing, auto unboxing, parsing strings to numeric values, and character checking methods.

Uploaded by

Bk Siri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Chapter 12

Library Classes

Concept of cmputer
class stream method

System .out. println( ) ;

System .out. println( ) ;

class stream
.
method
Library classes
System.out.println ( ) ;
;
a method . ( built in )
Primitive data types ---
predefined data types

Ex-- int , byte , short , long , float , double , boolean , char

.
Composite data type---
Data type which can be constructed using primitive
data type.

ex-- string is actually a collection of char data type.


User defined data type
Data type defined by user to perform some specific task is
known as user defined data type .

ex-- class
.
Creating object of a class ---

We use new operator to create object.


Class name object name = new classname ( )

Example --
1. A obj = new A ( ) ;
2. Calculator obj = new calculator ( ) ;

.
Accessing member variable
You can access member variable via the dot ( . ) operator.
Examples--
obj. num 1 = 10 ;
obj . num 2 = 5 ;

Accessing member method---

You can access member methods using the dot ( . ) operator.


Examples ---
obj. multiply ( ) ; .
Wrapper classes----
It allows you to convert a primitive data type into an
object type.

byte-- Byte
short -- Short
int -- Integer
long -- Long
float -- Float
double-- Double
char -- Character.
boolean -- Boolean
Auto boxing ---
Automatic conversion of primitive types into their
corresponding object wrapper classes.

example -- int a = 10 ;
Integer a = 10 ;

.
Auto unboxing---
Reverse process of autoboxing
Conversion of object wrapper classes into primitive types..
Example --- int a = 10 ;
Integer a = 10 ;
int b = a ;

.
Parsing string value to numeric .

converts string value into number form


"1255 " -- 1255
"3.69 " -- 3.69

1. Integer ---
parseInt ( string )
String s = " 1122 "
int a = Integer . parseInt
.
( string s ) ;
String to float

example--

string s = "34.11" ;

float a = Float . parseFloat ( s ) ;

.
Checking character methods ----

is Digit ( char )
Checks if char is a digit or not
is Letter ( char )
Checks if char is a Letter or not
is Letter or Digit ( char )
Checks if char is a Letter or Digit or not

.
class A
{
void dis
{
char ch1= '8' ;

char ch2 = ' ' ;

if ( Character.isLetter or Digit ( ch 1 ) ) ;
Sopln ( ch1 + " is a letter or digit " ) ;
else
Sopln ( ch1 + " is not a letter or digit ) ;
.
if ( Character. isWhitespace ( ch2 ) ) ;

Sopln ( ch2 + " is a whitespace " ) ;

else

Sopln ( ch2 + " is not a whitespace " ) ;

}
}
.
Determining character case method .
is lower case ( char )
is upper case ( char ).
class A
{
void dis ( )
{
char ch 1 = " A " ;
char ch 2 = " a " ;
if ( Character. is Lower case ( ch 1 ) ;
{
Sopln ( ch1 + " is lower
. case " ) ;
}
else
{
Sopln ( ch1 + " is not lower case " ) ;
}
if ( Character. is Uppercase ( ch2 ) )
{
Sopln ( ch2 + " is uppercase " ) ;
}
else
{
Sopln ( ch2 + " is not. upper case " ) ;
}
}
Changing character case --
toLowerCase ( char )
toUpperCase ( char )
class A Output
{ Original case : A
void dis ( ) After conversion : a
{
char ch1 = " A " ;
Sopln ( " Original case : " + ch1 ) ;
Sopln ( " After conversion : " + Character . toLowerCase ( ch1 ) ;
} .

You might also like