0
i need the code if i give grr grr it will show lion lion as input. But it shows no output.
5 Answers
0
Harithra Shanmugam
Here is my attempt you can do it with many other ways also.
https://code.sololearn.com/cOSAxfzP2rw5/?ref=app
+ 1
Store the grr and grr or so inputs in array ,then run a for loop and pass the switch(array[i])
+ 1
If you use loop then you have to use "if statement" to compare , the line of code will get increase.
As know that in "if else statement" we are checking the condition ,in "switch" we are checking exact match with "case".
+ 1
That's why passing that case as
Suppose
For(i=0;i<arr.length;i++){
Switch(arr[i])
Case:
}
,works fine according to me but I didn't tired so I can't say much,
0
In switch case it will match the exact value of "n" with the case.
switch(n)
{
case "Grr":
case "grr":
System.out.print("Lion");
break ;
}