Computers and Technology

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(){

}

}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 13:50, almostnevercbbc
Implement the dining philosophers problem (described on pages 167-170 in the textbook (chapter 2.5. create a graphical user interface - showing which philosopher is eating, and which is waiting/thinking at any given time. show the forks. use java programming language for this project.
Answers: 2
image
Computers and Technology, 23.06.2019 00:30, devenybates
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
image
Computers and Technology, 24.06.2019 16:00, bsrlee1115
Which type of cloud computing offers easily accessible software and applications on the machines
Answers: 1
image
Computers and Technology, 25.06.2019 03:10, lokiliddel
Write a program to convert a person's height in inches into centimetres #and their weight in stones into kilograms. (1 inch = 2.54 cm and 1 stone = 6.364 kg)
Answers: 1
Do you know the correct answer?
The String class is provided in the Java library. Provide your own implementation for the following...

Questions in other subjects:

Konu
Mathematics, 01.04.2021 08:10
Konu
Biology, 01.04.2021 08:10