Class 10 ICSE - Java

Class 10th Java aims to empower students by enabling them to build their own applications introducing some effective tools to enable them to enhance their knowledge, broaden horizons, foster creativity, improve the quality of work and increase efficiency.
It also develops logical and analytical thinking so that they can easily solve interactive programs. Students learn fundamental concepts of computing using object oriented approach in one computer language with a clear idea of ethical issues involved in the field of computing
Class 10th java topics includes revision of class 9th, constructors, user-defined methods, objects and classes, library classes , etc.

Strings

Introduction




  • String is an object that represents sequence of character values(alphabets,numbers,special characterises)

  • Strings are immutable(i.e,unchangeable)

  • They are always written in double quotes


Intialization :

Explicit

String s="Hello";String str="Hello_world123"

//s and str are names of the strings


Implicit

Scanner sc=new Scanner(System.in);
String s=sc.next();String str=sc.nextLine();

// next takes only a word as an input while nextline takes a sentence

String Functions





length()

This method is used to return the length of the string
Return Type:int
Example:

len function in a string

len function in a string



charAt(int)

This method returns the char value for a particular index
Return Type:char
Argument Type:int
Example:

charAt function in a string

charAt function in a string



trim()

This method is used to remove beginning and ending spaces of a string
Return Type:String
Example:

charAt function in a string

charAt function in a string



toLowerCase()

This method returns the string in lowercase
Return Type:String
Example:

lowercase function in a string

lowercase function in a string



toUpperCase()

This method returns the string in uppercase
Return Type:String
Example:

uppercase function in a string

uppercase function in a string



indexOf()

This method returns the first occurrence of the char value's index
Return Type:int
Argument Type:char
Example:

indexOf function in a string

indexOf function in a string



lastIndexOf()

This method returns the last occurrence of the char value's index
Return Type:int
Argument Type:char
Example:

lastindexof function in a string

lastindexof function in a string



concat()

This method is used to attach one string to another string
Return Type:String
Argument Type:String
Example:

concat function in a string

concat function in a string



equals(String)

This method compares two strings and returns true of equal and false of not
Return Type:boolean
Argument Type:String
Example:

equals function in a string

equals function in a string



equalsIgnoreCase(String)

This method compares two strings to find if they are equal or not,ignoring case difference
Return Type:boolean
Argument Type:String
Example:

equalsIgnoreCase function in a string

equalsIgnoreCase function in a string



compareTo(String)

This method compares two strings and returns the difference of ASCII values if different and 0 if equal
Return Type:int
argument Type:String
Example:

compareTo function in a string

compareTo function in a string



compareToIgnoreCase(String)

This method works same as compareTo function but ignoring case different
Return Type:int
argument Type:String
Example:

compareToIgnoreCase function in a string

compareToIgnoreCase function in a string



replace(old char,new char)

searches a string for a specified value,and returns a new string where the specified values are replaced

Return Type:String
argument Type:char
Example:

replace function in a string

replace function in a string



substring()

return a new string which is substring of a specified string
Return Type:String
Argument Type:int
Example:

substring function in a string

substring function in a string



startsWith()

This method checks whether a specified string starts with specified character or not
Return Type:boolean
Argument Type:String
Example:

startsWith function in a string

startsWith function in a string



endsWith()

This method checks whether a specified string ends with specified character or not
Return Type:boolean
Argument Type:String
Example:

endsWith function in a string

endsWith function in a string



valueOf(all types)

This method returns the string representation of the specified value
Example:

valueOf function in a string

valueOf function in a string



Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com