So I'm creating a class which when given three inputs uses them as sides of a triangle and tells ther user what type of triangle it is, or if the input is invalid, tells them why it is invalid. I'm readin the input as a string and then trying to split it into a string array, from there checking to see if it has 3 elements.. in which the data is good at that point, and then converting them to ints and checking to see if they're negative ansd finally checking to see if they can work as sides of a triangle ie a+b >c, a+c >b , b+c >a.
I'm trying to split it into an array of strings but am getting an error, and can't seem to figure out why as this should be working from what I've read of the string.split method online.
import java.util.*; public class TriangleTest{ private int sideA; private int sideB; private int sideC; public static void main(String[] args){ TriangleTest triangle = new TriangleTest("3 4 5"); } //end main public TriangleTest(String input) { String[] toAnalyze = input.split(" "); // System.out.println(toAnalyze); TestAmount(toAnalyze); }// end triangletest public void TestAmount(String[] input) { if (input.length > 3) {System.out.println("Please enter three valid side lengths seperated by spaces, you've entered more then 3"); } else if (input.length < 3) { System.out.println("Please enter 3 valids side lengths, you've entered more then 3"); } // System.out.println(sideA + sideB + sideC); }//end testAmount public void TestNegative(char[] input) { }
the output reads [Ljava.lang.String;@15db9742