Hi, In your code you have assigned a String to a char variable which is incompatible and hence the error. A char type value should be enclosed in single quote. If you use double quotes, it will be treated as a String.
Regards, Babu On Thu, Jul 23, 2009 at 5:30 AM, tinyang <[email protected]> wrote: > Hi all. > > Here is my code for MyGreatestValueProject2. I'm getting a "Incompatible > types" compile error on the following line: > min = (zero < num3) ? "The smallest number is less than 10!" : "The > smallest number is greater than or equal to 10!"; > > I think I understand the problem which is declaring min as a char variable > type, then saying it equals an equasion with intergers in it, but I'm not > sure how to fix it. Can someone give me a hint or explain to me how this > should be done and why? Thanks! > > ----------------------Code--------------------------------- > > public class GreatestValue2 { > > /** > * @param args the command line arguments > */ > public static void main(String[] args) { > // TODO code application logic here > > //declares the numbers > int num1 = 10; > int num2 = 23; > int num3 = 5; > int max = 0; > int zero = 0; > char min = ""; > > //determines the highest number > max = (num1 > num2) ? num1 : num2; > max = (max > num3) ? max : num3; > > zero = (num1 < num2) ? num1 : num2; > min = (zero < num3) ? "The smallest number is less than 10!" : "The > smallest number is greater than or equal to 10!"; > > //prints the output on the screen > System.out.println("number 1 = " + num1); > System.out.println("number 2 = " + num2); > System.out.println("number 3 = " + num3); > System.out.println("The highest number is = " + max); > System.out.println(min); > } > > } > > > -- > J > P Please don't print this e-mail unless you really need to. > > <http://www.crossloop.com/Teenah> > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
