Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyString
- {
- private int vector[];
- private int j , ct = 0;
- public MyString(int values[])
- {
- for(int i = 0; i < values.length; i++)
- {
- vector[i] = values[i];
- j = i;
- }
- }
- public int length()
- {
- return j;
- }
- public int valueAt(int position)
- {
- return (vector[position] != null) ? vector[position] : -1;
- }
- public boolean contains(int value)
- {
- for(int i = 0; i < vector.length; i++)
- {
- if(vector[i] == value)
- return true;
- }
- return false;
- }
- public int count(int value)
- {
- for(int i = 0; i < vector.length; i++)
- {
- if(vector[i] == value)
- ct++;
- }
- return ct;
- }
- public String toString()
- {
- String buffer = "";
- for(int i = 0; i < vector.length; i++)
- {
- buffer += " " + vector[i];
- }
- return buffer;
- }
- }
- public class Main {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement