Ask Experts Questions for FREE Help !
Ask
    oneoderja's Avatar
    oneoderja Posts: 2, Reputation: 1
    New Member
     
    #1

    Sep 30, 2012, 07:28 PM
    Java Question of passing an Array into a method
    Define an integer array ‘arr’ with size 2 in the main method and initialize the two elements in ‘arr’ to be 1 and 2
    Write a method ‘swap’ and pass the ‘arr’ into the method, swap two elements of the ‘arr’ in the method
    Print out all elements in ‘arr’ in the main method
    System.out.print(arr[0] + ‘ ‘ + arr[1]);
    Swap(arr);
    System.out.print(arr[0] + ‘ ‘ + arr[1]);

Check out some similar questions!

Need help into passing the object into the method and make it work [ 0 Answers ]

Define a class called ‘twoInt’ with two public integer fields a and b In the constructor of ‘twoInt’, initialize the a and b to be 1 and 2 Create an instance ‘mytwoInt’ in the main method Write a method ‘swap’ (not the method of the class ‘twoInt’) and pass the above instance ‘mytwoInt’ into the...

Unknown Array Java Error [ 3 Answers ]

I'm having a problem with some java code involving an array and I don't understand the error that appears: CD.java:67: array required, but CDDriver found System.out.println(myCD); I am trying to print out the total of all the prices that are in the array Any help would be great here is...

Java: using an array from the main in a method [ 2 Answers ]

I have the array names in the main of my program and I want to use it in a method FindName.. How would I wright the method header and the call to the method in the main?

Java Error: array required, but PRmList found [ 2 Answers ]

Here is my code: I get the error: Array required, but PRmList found. Any help would be GREATLY appreciated. Thanks! Public class PRm { Private String PRm; Private String movieTitle; Private String movieRating; Private int seats;


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.