Is there anybody could tell me what does this function use for?For example :
String strTemp = JOptionPane.showInputDialog(null,"Please Enter C To Open A Current Account \n Or J To Open A Joint Account"); switch(strTemp.charAt(0)){ case 'c': case 'C': //code statement break; case 'j': case 'J': }
Basically if i program the statement in c++ ,i would coding it in this form
switch(strTemp) { case 'c': case 'C': //code statement break; case 'j': case 'J': }
But it won't work in java ,while i try to compile it an error prompt out mentioned that ("invalid type" in switch(strTemp)) So why ?