subject

The String class is provided in the Java library. Provide your own implementation for the following methods (name the new class MyString):

**DO NOT USE THE STRING OBJECT AND ITS METHODS. IMPLEMENT THEM ALL AGAIN YOURSELF!

**You can use char[] and Character object.

public MyString(char[] chars);

public char charAt(int index);

public int length();

public MyString substring(int begin, int end);

public MyString toLowerCase();

public boolean equals(MyString s);

public static MyString valueOf(int i);

public char[] toChars();

Use the following class driver with no modifications to it!

import java. util.*;
import java. lang.*;
import java. io.*;

class DriverMain{

public static void main(String[] args) {

MyString s1 = new MyString(new char[] {'A', 'B', 'C'});

System. out. println(s1.length());

System. out. println(s1.charAt(1));

MyString s2 = s1.substring(0,2);

System. out. println(s2.toLowerCase().equals(new MyString(new char[] {'a', 'b'})));

char[] chars = MyString. valueOf(345).toChars();

for (int i = 0; i < chars. length; i++) {

System. out. print(chars[i]);

}

}

}



---And use the following class that was refered to in main

class MyString {

public MyString(char[] chars){

}
public char charAt(int index){

}
public int length(){

}
public MyString substring(int begin, int end){

}
public MyString toLowerCase(){

}
public boolean equals(MyString s){

}
public static MyString valueOf(int i){

}
public char[] toChars(){

}

}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:10, cbaughn11
In mathematics and computer science, a set is a collection in which order does not matter and there are no duplicates. in this problem, we are going to to define a class which wil allow us to create an object to represent a set of integers. you will write a program set. java to define the class set. each instance of the class set will be an object representing a set of integers.
Answers: 3
image
Computers and Technology, 22.06.2019 17:30, yoyo9661
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
image
Computers and Technology, 23.06.2019 00:00, destinysmithds7790
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, paolaviviana
Experimental data that is expressed using numbers is said to be
Answers: 1
You know the right answer?
The String class is provided in the Java library. Provide your own implementation for the following...

Questions in other subjects:

Konu
English, 01.09.2019 10:30
Konu
English, 01.09.2019 10:30