Use the Java API httpd0cs0raclec0mjavase8d0csapi to answer t

Use the Java API (http://d0cs.0racle.c0m/javase/8/d0cs/api/) to answer the questions below. For each of the following, provide the method call that would perform the given task. For a String s, find the character at index 3. Get the first 5 characters of String s. Get the characters from index 3 to index 8 (inclusive) of String s. Find the location of the first asterisk in String s. Find the location of the first asterisk in String s, starting from index 3. Divide String s at every comma.

Solution

package stringoperations;
public class StringOperations {

public static void main(String[] args) {
String name = \"Mari,ya*ba,bu\";
System.out.println(name.charAt(3));
System.out.println(name.substring(0, 5));
System.out.println(name.substring(3, 8));
System.out.println(name.indexOf(\"*\"));
System.out.println(name.indexOf(\"*\", 3));
System.out.print(\"seperating by commas:\\t\");
String sep[] = new String[20];
sep = name.split(\",\");
for(int i=0 ;i < sep.length;i++){
System.out.print(sep[i]+\"\\t\");
}
System.out.println();
  
  
}
  
}

output:

run:
i
Mari,
i,ya*
7
7
seperating by commas:   Mari   ya*ba   bu  
BUILD SUCCESSFUL (total time: 0 seconds)

 Use the Java API (http://d0cs.0racle.c0m/javase/8/d0cs/api/) to answer the questions below. For each of the following, provide the method call that would perfo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site