Check out example codes for "switch case count characters in string". It will help you in understanding the concepts better.

Code Example 1

Scanner keyboard = new Scanner(System.in);
//string
	String name;
//int
	int stringSize;
	System.out.print("Enter a name: ");
	// the name entered
	name = keyboard.nextLine();
	// counting the lenght of the name and making it an int
	stringSize = name.length();
	// switching with the int value not the string
	switch (stringSize)
	{
		case 1:
		case 2:
		case 3:
		System.out.println("This name has 3 or less characters");
		break;

		case 4:
		System.out.println("This name has 4 characters");
		break;
    }

Learn ReactJs, React Native from akashmittal.com