How to use array from one method in another?

user2956231

I find problem to use array form one method in another method.

In first method I take input from user and saved data to two arrays.

In second method I have to shows these information from array.

import java.util.Scanner;

public class MarkCalculator {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        computeMark();
        computeResult();
    }

    public static void computeMark ()
    {

        Scanner exam = new Scanner (System.in);
        Scanner coursework = new Scanner (System.in);

        int num = 12;
        int[] exam_grade = new int[num];
        int[] coursework_grade = new int[num];

        for (int i=0+1; i<3; i++){

           System.out.printf(i+". Modelue"+" Enter grade of exam:");
           exam_grade[i]=exam.nextInt();

           System.out.printf(i+". Modelue"+" Enter grade of coursework:");
           coursework_grade[i]=coursework.nextInt();   
        }

        System.out.println();   
        System.out.println();
        System.out.println("Your grades are: ");


    }


    public static void computeResult (int[] coursework_grade, int[] exam_grade)
    {

        for (int i = 0+1; i<3; i++) {

            System.out.println(i+". Module: "+ "Exam: "+exam_grade[i]+" Coursework: "+coursework_grade[i]);

        }

    }



}

The problem is, I have no idea how to pass information from array to the second method. I couldn't find any solution. Can someone help me pls?

Thanks.

Thirumalai Parthasarathi

this is all it takes.

computeResult(coursework_grade,exam_grade);

you can pass an array or any object to a method as you would do with a primitive type. But remember when passing an object if the object's state is changed in the called method it gets reflected in the object itself and all references of the object would contain the affected object.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use array from one method in another?

From Dev

How can I use a string from an array in one method in another?

From Dev

How to use array from one function, inside another function

From Dev

How to use one array as keys for another array?

From Dev

How to get variables from one static method and use them in another method

From Dev

How can I use insert_id from one method in model in another method in the same model

From Dev

How to reference a 'var' from one method in another?

From Dev

How to call a Method from one class to another

From Dev

How to call parameters from one method to another?

From Dev

How to use the variable of one method in another method in Java(android)

From Dev

How do I fill a String array in one method with data from another?

From Dev

How do I use a remote method in one model to return info from another model?

From Dev

How to use input from another method?

From Dev

How to use getProperty from another method? (Java)

From Dev

How to add values from one array to another?

From Dev

How to use data from one class into another?

From Dev

How to use a macro from one crate in another?

From Dev

How to use an ArrayList from one class in another?

From Dev

How to copy file from one use to another?

From Dev

How to call one method from another method in javascript?

From Dev

Java can't use public method from one package in the another

From Dev

How to get values from one array based on another array?

From Dev

How can I remove object in one array from another array?

From Dev

How to inject an Array from one Service into an array of another service in Angular

From Dev

How can I remove object in one array from another array?

From Dev

how to pass data from one array list to another array list

From Dev

How to compare the elements from one array in another array

From Dev

How to subtract one object array literally from another object Array

From Dev

How to Print a specific point from an array from another method ? #Java

Related Related

  1. 1

    How to use array from one method in another?

  2. 2

    How can I use a string from an array in one method in another?

  3. 3

    How to use array from one function, inside another function

  4. 4

    How to use one array as keys for another array?

  5. 5

    How to get variables from one static method and use them in another method

  6. 6

    How can I use insert_id from one method in model in another method in the same model

  7. 7

    How to reference a 'var' from one method in another?

  8. 8

    How to call a Method from one class to another

  9. 9

    How to call parameters from one method to another?

  10. 10

    How to use the variable of one method in another method in Java(android)

  11. 11

    How do I fill a String array in one method with data from another?

  12. 12

    How do I use a remote method in one model to return info from another model?

  13. 13

    How to use input from another method?

  14. 14

    How to use getProperty from another method? (Java)

  15. 15

    How to add values from one array to another?

  16. 16

    How to use data from one class into another?

  17. 17

    How to use a macro from one crate in another?

  18. 18

    How to use an ArrayList from one class in another?

  19. 19

    How to copy file from one use to another?

  20. 20

    How to call one method from another method in javascript?

  21. 21

    Java can't use public method from one package in the another

  22. 22

    How to get values from one array based on another array?

  23. 23

    How can I remove object in one array from another array?

  24. 24

    How to inject an Array from one Service into an array of another service in Angular

  25. 25

    How can I remove object in one array from another array?

  26. 26

    how to pass data from one array list to another array list

  27. 27

    How to compare the elements from one array in another array

  28. 28

    How to subtract one object array literally from another object Array

  29. 29

    How to Print a specific point from an array from another method ? #Java

HotTag

Archive