im studying from a book called "intro to java programming(10th edition)" it seems easy and all until i try to make a method, i just end up keeping them all in the main method.
Is there any good videos out there that you guys know of that can help me understand the how to methods?
Like this program (exercise 7.9):
letting user input 10 integers and displaying the minimum.
import java.util.*; public class Exercise_7_09 { public static void main(String[] args) { double[] minimum = new double[10]; Scanner input = new Scanner(System.in); System.out.print("Enter the " + minimum.length + " values: "); minimum[0] = input.nextDouble(); double min = minimum[0]; for(int i = 1; i < minimum.length; i++) { minimum[i] = input.nextDouble(); if(min > minimum[i]) { min = minimum[i]; } } } public static double[] min(double[] array) { array = new double[10]; if(min > minimum return array; } }
i didn't complete it yet but you can see that i can simply place it in main. methods are suppose to help make the code a little easier but i'm confused on how to use them correctly.
Thanks!