Get Started with Actividad-1
This guide will walk you through compiling and running the Actividad-1 program. You’ll learn how to set up the environment, compile the Java source code, and execute the program with sample data.Prerequisites
Before you begin, ensure you have:- Java Development Kit (JDK) installed (version 8 or higher)
- Access to a terminal or command prompt
- The
Main.javasource file
You can verify your Java installation by running
java -version in your terminal.Installation & Execution
Navigate to the source directory
Open your terminal and navigate to the directory containing
Main.java:Compile the Java program
Compile the source code using the Java compiler:This will generate a
Main.class file in the same directory. If you see no output, the compilation was successful.Enter values for the first array
You’ll see a prompt to enter 7 values for the first array. Enter each value and press Enter:
Complete Example Session
Here’s what a complete terminal session looks like:Understanding the Code
The program consists of several key sections:Array Declaration
Reading Input
Scanner class reads integer values from the console, and a loop iterates through each array position.
Calculating Differences
Computing the Average
double for decimal precision.
Troubleshooting
Input Mismatch Exception
If you enter non-integer values, the program will throw an
InputMismatchException. Make sure to enter only whole numbers.Command Not Found
If
javac or java commands are not recognized, verify that the JDK is installed and added to your system PATH.Next Steps
Now that you’ve successfully run the program:Main Class
Explore detailed explanations of the Main class
Array Operations
Learn about array operations and calculations
Input Format
Understanding input requirements
Output Format
Understanding program output