Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package taskone;
  2.  
  3. import java.util.*;
  4.  
  5. class Arrayplus1 {
  6.  
  7. int x;
  8. int data[];
  9.  
  10. void example(int x) {
  11. this.x = x+1;
  12. this.data= new int[x];
  13. }
  14.  
  15. void increaseSizeOfArray(int incrementSize) {
  16. int copiedArray[] = Arrays.copyOf(data, data.length + incrementSize);
  17. data = copiedArray;
  18.  
  19. }
  20.  
  21. void printall() {
  22. System.out.println(Arrays.toString(data));
  23. }
  24. }
  25.  
  26. public class TaskOne {
  27.  
  28. public static void main(String[] args) {
  29. example task = new example();
  30. task.printall();
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement