2 Error Messages:// Practical 1B - Question 2 // Marcus Ward // 27/01/2012 // Program asking user for two strings, and then it will display the longest string on screen. import java.util.Scanner; public class LongestString { public static void main(String[] args) { Scanner keyboardIn = new Scanner(System.in); String one = new String(); // declare variables String two = new String(); int num1, num2; System.out.print("Please enter the first string: "); one = keyboardIn.nextLine(); System.out.print("Please enter the second string: "); two = keyboardIn.nextLine(); num1.length(); num2.length(); if(num1>num2) { System.out.println(one + " is the longest string."); } else { System.out.println(two + " is the longest string."); } } }
LongestString.java:24: int cannot be dereferenced
num1.length();
^
LongestString.java:25: int cannot be dereferenced
num2.length();
^