• +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Online Customer Service
Follow Us:

Java Strings Homework Help

Java Strings

The sequence of characters is called strings. In java provides strings as a class to manipulating functions.

Creating strings:

String s1=”hai”;

String length:

The length method is used to find the length of the particular string.

Example:

public class sample {
 public static void main(String args[])
{
 String s1 = "my name is mani";
 int length = s1.length();
 System.out.println( "String Length is : " + length );
 }
}

Output:

String Length is : 15

Concatenating strings:

It is used to concatenate the two strings.

Example:

public class sample
 {
 public static void main(String args[]) {
 String s1 = "my name is";
 System.out.println(+s1 + "mani");
 }
}

Output:

my name is mani

String methods:

There are many methods are available for manipulating strings using string class.

1. Char charAt(int i) – return ith index character

“welcome”.charAt(4); result c

2. String substring (int i) – return substring from ith index

“welcome”.substring(5); result me

3. String substring (int I, int j) – return substring from ith index to jth index

“welcome”.substring(2,5); result lco

4. Int indexOf(string s) – return index of string first occurrence

String s =” my name is mani”

Int o= s.indexOf(“mani”); result 11

5. Int lastindexOf(string s) – return index of string last occurrence

String s =” my name is mani”

Int o= s.indexOf(“n”); result 13

Like that many string methods are available in java.

PLACE ORDER NOW

Resources

  • 24 x 7 Availability.
  • Trained and Certified Experts.
  • Deadline Guaranteed.
  • Plagiarism Free.
  • Privacy Guaranteed.
  • Free download.
  • Online help for all project.
  • Need Assignment Help

Testimonial

Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak:
Read More

Tap to Chat
Get Instant Assignment Help
Tap to Chat
Get Instant Assignment Help