Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.Serializable;
- public class MyString implements Serializable {
- private String theString;
- private int stringLength;
- public MyString(){
- theString = "";
- stringLength = 0;
- }
- public MyString(String s){
- theString = s;
- }
- public void setTheString(String theString) {
- this.theString = theString;
- }
- public String getTheString() {
- return theString;
- }
- public void setStringLength(int l){
- this.stringLength = l;
- }
- public int getStringLength(){
- return stringLength;
- }
- public String reverseTheString(){
- String reverse = "";
- for (int i = theString.length() - 1; i >= 0; i--)
- reverse += theString.charAt(i);
- return reverse;
- }
- public int determineLength(){
- return theString.length();
- }
- public String getSubString(){
- String subString = "";
- for (int i = 0; i < theString.length() - 2; i++)
- subString += theString.charAt(i);
- return subString;
- }
- public String toString(){
- return String.format("String: %s Length: %d", theString, stringLength);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement