• Forums
  • View New Posts
  • View Today's Posts
  • Search
  • Members
  • Calendar
  • Help
  • Extras
Forum stats
Show team
View New Posts
View Today's Posts
Lowlands Tactical: Forum
Login to account Create an account
Login
Username/Email:
Password: Lost Password?
 

  Lowlands Tactical: Forum Publiek Speeltuin
1 2 Next »
De grote programmeer opdracht 2016!

Thread Modes
De grote programmeer opdracht 2016!
Archu Offline
Lid
**
Posts: 43
Threads: 4
Joined: Sep 2014
Reputation: 2
#4
08-10-2016, 04:00 PM
Fur Java:

Code:
public class CopyArrays {

    static ArrayList arr1 = new ArrayList();
    static ArrayList arr2;

    private static ArrayList<Integer> randomize(ArrayList<Integer> array) {

        Integer cnt1;
        Random rndm = new Random();

        for (int i = 0; i < 10; i++) {
            cnt1 = rndm.nextInt(100);
            array.add(cnt1);
        }
        return array;
    }

    public static void main(String[] args) {

        randomize(arr1);
        arr2 = (ArrayList<String>) arr1.clone();
        arr1.set(9, "-7");

        System.out.println("Array 1: " + arr1 + "\n" + "Array 2: " + arr2);
    }
}


Result:
Quote:Array 1: [77, 38, 3, 37, 58, 48, 27, 18, 16, -7]

Array 2: [77, 38, 3, 37, 58, 48, 27, 18, 16, 42]
Find
Reply
Share Thread:            


Messages In This Thread
De grote programmeer opdracht 2016! - Sacha - 08-10-2016, 03:13 PM
RE: De grote programmeer opdracht 2016! - Sacha - 08-10-2016, 03:15 PM
RE: De grote programmeer opdracht 2016! - PingWing - 08-10-2016, 03:44 PM
RE: De grote programmeer opdracht 2016! - Archu - 08-10-2016, 04:00 PM
RE: De grote programmeer opdracht 2016! - Sacha - 08-10-2016, 07:31 PM
RE: De grote programmeer opdracht 2016! - Sacha - 08-11-2016, 11:09 AM

  • View a Printable Version
  • Subscribe to this thread


Users browsing this thread:
1 Guest(s)

  • Contact Us
  • Forum team
  • Forum stats
  • Return to Top
 
  • RSS Syndication
  • Lite mode
  • Lowlands Tactical
  • Help
 
Forum software by © MyBB - Theme © iAndrew 2014



Linear Mode
Threaded Mode