Java Main Method Called -


How can I and other methods in Java call the main method? Please explain using the code given below:

  public class arraysAndmethods {public zero print (double [] arr) {int x = public arraysAndMethods.main (int [] studGrades); // For other methods in main Mehthod // Pass ARR / int one = main (args []); For (Int i = 0; I & lt; StudGrid.Linght; I ++) system. Out.print (studgaredes [i] + ""); } // printArray method end / public static zero main (string rule []) {java.util.Scanner input = new java.util.Scanner (System.in); // Input Scanner System.out.println ("What is the class size?"); Int n = input.nextInt (); Double studded [] = new double [n]; For (Int I = 0; i & lt; studGrades.length; i ++) {System.out.println ("What is student's grade #" + (i + 1)); Standard Gradient [i] = Input NXD double (); } // End of loop} // After the end of the main method // edit the end of the // class  

:

I have thought out and left the debate Is I going to use the return value from the main? And since the returns value from the main is an array, then the parameters of the main call should be placed in brackets? Should there be a price between those brackets?

  public squares arraysAndmethods {public zero printRere (double [] arr) {int x = arraysAndMethods.main (double [i] arr); // For error with the parametres (int i = 0; i & lt; studgrade lihat; i ++) system. Out.print (studreds [i] + ""); } // printArray method public static double [] main (string array []) {// double array java.util.Scanner input = new java.util.Scanner (System.in); // Input Scanner System.out.println ("What is the class size?"); Int n = input.nextInt (); Double [] arr = new double [n]; // (NI = 0; i & lt; arr.length; i ++) {// Input Grade for each student} System.out declare and start the array for many elements. Println ("What is the student's grade" + (i + 1)); Arr [i] = input.nextDouble (); } // Return loop for end arrow; } // main end of the end method / end of class  

This is usually It is believed that in order to call the main method by any other method, poor programming practice can be a complete list of problems like infinite loop, infinite recursion etc. Your main way should be high-level functionality, which requires your program to operate, you usually want it to be kept. Ask yourself as a good "check", can I create this functionality in my own method? If that's the case then why not? Then if you ever need to recreate that call, then you have a different method to do this.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -