This was my introduction into coding Java. The main idea of this code is to demonstrate several concepts in Java programming, particularly string manipulation, parsing, and basic algorithms. Here's a breakdown of what the code is trying to accomplish:
String Manipulation (in the pstarr class):
It starts with a string " 2 12 / 25 " and demonstrates how to trim and split it. It shows how to parse parts of the string into integers. It creates an array of integers from the string, ignoring the "/" character.
Greatest Common Divisor (GCD) Calculation (in the Utility class):
The findGCD method implements the Euclidean algorithm to find the GCD of two numbers.
User Input Handling (in the Utility class):
The inputData method demonstrates how to safely get integer input from a user, including error handling for non-integer inputs.
Demonstration of Usage (in the Test class):
It shows how to use the inputData method to get two numbers from the user. It then calculates and prints the GCD of these two numbers using the findGCD method.
Overall, this code serves as a tutorial or practice exercise covering:
String manipulation and parsing Array handling Simple algorithms (GCD calculation) User input and error handling Basic object-oriented programming concepts (using static methods in utility classes)