Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Trouble passing parameters!

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Cool Trouble passing parameters!

    I'm trying to write a method that expects an array of int and two intS parameters, which represent the starting position and ending position of a subarray within the parameter array.

    So here's the code I've written, trying to do this, but I'm getting errors having to do with the parameter passing. I don't think I'm doing it quite right, clearly...

    I aim for the output of '10 11 12'.
    Please help!

    public class testing{
     
    public static void main(String args[])
    {
    int[]firstArray = {8, 9, 10, 11, 12, 13};  //original string
    subArray(int[]firstArray, 2, 4);  //trying to pass these parameters to method subArray
     
    public static void subArray (int[]originalArray, int S2, int S2) //parameters - trying to get from previous line. 
    {
    	int[] copy = new int[3]          //Instantiating new array to fill with contents from original array.
    	System.arraycopy(originalArray[], 1, copy[], 0, 3);      //copying over contents...
     
    	for (int i = 0; i < copy.length; i++){
    			System.out.println(copy[i]);} // Will produce contents of new array 'copy'
    }
    }}


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,197
    Thanks
    49
    Thanked 2,172 Times in 2,145 Posts

    Default Re: Trouble passing parameters!

    I'm getting errors
    Please copy and paste here the full text of the error message.

Similar Threads

  1. Trouble passing array in parameters
    By AngryCrow in forum Collections and Generics
    Replies: 2
    Last Post: September 12th, 2011, 09:49 AM
  2. Help using parameters
    By white97 in forum Object Oriented Programming
    Replies: 6
    Last Post: August 9th, 2011, 07:28 PM
  3. Actual and Formal Parameters
    By mikec2500 in forum Object Oriented Programming
    Replies: 4
    Last Post: February 10th, 2011, 07:48 AM
  4. formal and actual parameters
    By gemma in forum Java Theory & Questions
    Replies: 3
    Last Post: December 7th, 2010, 10:14 AM
  5. New to vectors passing parameters
    By osmaavenro in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 30th, 2010, 04:32 PM