<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Tech-Recipes - Latest Comments in Java switch/case statement syntax</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><atom:link href="https://tech-recipes.disqus.com/java_switchcase_statement_syntax_java_programming_tech_recipes/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sat, 16 Jul 2011 01:29:23 -0000</lastBuildDate><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-253391798</link><description>&lt;p&gt;IS it need to Use Breaks in dEfault?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">man-man</dc:creator><pubDate>Sat, 16 Jul 2011 01:29:23 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-244042226</link><description>&lt;p&gt;hmm.. h0w ab0ut   &lt;/p&gt;&lt;p&gt;char a; &lt;br&gt;    a = (char)&lt;a href="http://System.in.read" rel="nofollow noopener" target="_blank" title="System.in.read"&gt;System.in.read&lt;/a&gt;();&lt;br&gt;        switch (a){  &lt;br&gt;   case a:&lt;br&gt;        System.out.println("Less 10% :" + (x-x*0.10));&lt;br&gt;        break;&lt;br&gt;   case b:&lt;br&gt;        System.out.println("Penalty 5% :" + (x+x*0.05+x));&lt;br&gt;        break;&lt;br&gt;   case c:&lt;br&gt;        System.out.println("Penalty 10% :"+ (x+x*0.10));&lt;br&gt;        break;&lt;/p&gt;&lt;p&gt;what express|0n sh0uld | use??? s0 |t can read the char? 0r case a case b case c???&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Shimmer_boy3</dc:creator><pubDate>Wed, 06 Jul 2011 09:40:56 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-230834986</link><description>&lt;p&gt;import java.util.Scanner;public class switchDemo {&lt;br&gt;      public static void main(String[] args) {&lt;br&gt;        Scanner inputDevice = new Scanner(&lt;a href="http://System.in" rel="nofollow noopener" target="_blank" title="System.in"&gt;System.in&lt;/a&gt;);        System.out.println("Enter a number for a month");        int iUserInput = inputDevice.nextInt();&lt;br&gt;                   switch (iUserInput) {            case 1:  System.out.println ( "January" );     break;            case 2:  System.out.println ("February");      break;            case 3:  System.out.println ("March");         break;            case 4:  System.out.println ("April");         break;            case 5:  System.out.println ("May");           break;            case 6:  System.out.println ("June");          break;            case 7:  System.out.println ("July");          break;            case 8:  System.out.println ("August");        break;            case 9:  System.out.println ("September");     break;            case 10: System.out.println ("October");       break;            case 11: System.out.println ("November");      break;            case 12: System.out.println ("December");      break;            default: System.out.println ("Invalid month"); break;                    }}}&lt;br&gt;  &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nadzirah_orangeleo</dc:creator><pubDate>Tue, 21 Jun 2011 02:51:49 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-153653143</link><description>&lt;p&gt;i dont know&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">The_Lugdog</dc:creator><pubDate>Mon, 21 Feb 2011 19:54:44 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-130677108</link><description>&lt;p&gt;can i use multiple choice in case of SELECT......CASE statement ? i.e.&lt;/p&gt;&lt;p&gt;select (expression)&lt;br&gt;{&lt;br&gt;case "a" or "A":&lt;br&gt;system.println("vovel");&lt;br&gt;break;&lt;br&gt;case "a" or "A":&lt;br&gt;system.println("vovel");&lt;br&gt;break;&lt;/p&gt;&lt;p&gt;case "e" or "E":&lt;br&gt;system.println("vovel");&lt;br&gt;break;&lt;/p&gt;&lt;p&gt;default:&lt;br&gt;system.println("Ashish you r wrong.");&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ashish Narola Rajkot</dc:creator><pubDate>Tue, 18 Jan 2011 12:20:37 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-128708136</link><description>&lt;p&gt;If you need to switch over a value that is a string you can embed it into an Enum:&lt;/p&gt;&lt;p&gt;public class Example{&lt;br&gt;  enum Values { a, b, c }&lt;br&gt;  public static void main(String[] args) {&lt;br&gt;    Values v = Values.a;&lt;/p&gt;&lt;p&gt;    switch() {&lt;br&gt;      case a:&lt;br&gt;        //TODO&lt;br&gt;        break;&lt;br&gt;     case b:&lt;br&gt;       //TODO&lt;br&gt;       break;&lt;br&gt;     case c:&lt;br&gt;       //TODO&lt;br&gt;       break;&lt;br&gt;    }&lt;br&gt;  }&lt;br&gt;}&lt;/p&gt;&lt;p&gt;Regards&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sajmmon</dc:creator><pubDate>Thu, 13 Jan 2011 13:18:38 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-107232739</link><description>&lt;p&gt;i have the same question as kiabaman...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Student</dc:creator><pubDate>Sun, 05 Dec 2010 10:12:16 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-96618649</link><description>&lt;p&gt;can someone tell me how to make the "case "#" " have more than one character in the ' '?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">kiabaman</dc:creator><pubDate>Fri, 12 Nov 2010 14:35:02 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-89662830</link><description>&lt;p&gt;it is possible to make a loop between cases?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/"> jose</dc:creator><pubDate>Sun, 24 Oct 2010 13:33:16 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-89469177</link><description>&lt;p&gt;well i need help well m in 10 aand i hv project in computer to make software type programs..&lt;br&gt;so i wanted to knw tht whether i can insert a program related to one of the options in the case???&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sherral</dc:creator><pubDate>Sat, 23 Oct 2010 13:43:08 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-84681922</link><description>&lt;p&gt;yes&lt;/p&gt;&lt;p&gt;switch (int){&lt;br&gt;case 1:&lt;br&gt;      if (x = y) {&lt;br&gt;           class();&lt;br&gt;      }&lt;br&gt;case 2:&lt;br&gt;      if (x = y) {&lt;br&gt;           class2();&lt;br&gt;      }&lt;br&gt;default:&lt;br&gt;     class3();&lt;br&gt;}&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Papablopo</dc:creator><pubDate>Wed, 06 Oct 2010 16:01:25 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-76722789</link><description>&lt;p&gt;is if else if statement inside a switch statement possible?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">justAsking</dc:creator><pubDate>Fri, 10 Sep 2010 12:45:14 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-76722626</link><description>&lt;p&gt;is if else if statement inside a switch statement possible?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">justAsking</dc:creator><pubDate>Fri, 10 Sep 2010 12:44:23 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-30257023</link><description>&lt;p&gt;f*** * m*** f***&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jkbljkblpiub</dc:creator><pubDate>Mon, 18 Jan 2010 13:37:19 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-30256969</link><description>&lt;p&gt;this is all bulshit i failed my test cuz of this..i had totaly rong stuf.&lt;/p&gt;&lt;p&gt;F******* u&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">jkbljkblpiub</dc:creator><pubDate>Mon, 18 Jan 2010 13:36:46 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-27348252</link><description>&lt;p&gt;Very good piece of knowledge. Exactly what i was looking for. Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McTOM</dc:creator><pubDate>Sun, 27 Dec 2009 15:53:06 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-16214088</link><description>&lt;p&gt;since you are using characters try using '  ' (Single quotes) instead of using " "  double quotes&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">mohd</dc:creator><pubDate>Tue, 08 Sep 2009 17:40:29 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-14610320</link><description>&lt;p&gt;You cannot use strings on Swithc, you can only use int.  So, it would be a better idea to capture the lettes ascii code and evaluate your switch accordingly.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">estiven</dc:creator><pubDate>Mon, 10 Aug 2009 21:55:10 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-13810547</link><description>&lt;p&gt;import &lt;a href="http://java.io" rel="nofollow noopener" target="_blank" title="java.io"&gt;java.io&lt;/a&gt;.*;&lt;br&gt;import &lt;a href="http://java.net" rel="nofollow noopener" target="_blank" title="java.net"&gt;java.net&lt;/a&gt;.*;&lt;br&gt;public class SvowelDPS&lt;br&gt; {&lt;br&gt;	public static void main(String args[]) throws Exception&lt;br&gt;	{&lt;br&gt;		DatagramSocket ds=new DatagramSocket(40000);&lt;br&gt;		byte rb[]=new byte[100];&lt;br&gt;		System.out.println("Connection");&lt;/p&gt;&lt;p&gt;		DatagramPacket dp=new DatagramPacket(rb,rb.length);&lt;br&gt;		ds.receive(dp);&lt;br&gt;		System.out.println("Receive Data:"+new String(dp.getData()));&lt;br&gt;		String str=new String(dp.getData());&lt;br&gt;		String res="";&lt;br&gt;		str=str.trim();&lt;br&gt;		switch(str)	//error on this point.How can i do?&lt;br&gt;		{&lt;br&gt;			case "a":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "A":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "e":&lt;br&gt;				res=("Vowel");			&lt;br&gt;				break;&lt;br&gt;			case "E":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "i":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "I":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "o":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "O":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "U":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			case "o":&lt;br&gt;				res=("Vowel");&lt;br&gt;				break;&lt;br&gt;			default:&lt;br&gt;				res=("Not Vowel");&lt;br&gt;				break;&lt;br&gt;		}&lt;/p&gt;&lt;p&gt;		InetAddress cipadd=dp.getAddress();&lt;br&gt;		int cport=dp.getPort();&lt;br&gt;		byte sb[]=new byte[100];	&lt;br&gt;		sb=res.getBytes();&lt;br&gt;		DatagramPacket dpsend=new DatagramPacket(sb,sb.length,cipadd,cport);	&lt;br&gt;		ds.send(dpsend);&lt;br&gt;		System.out.println("Data send")	;&lt;br&gt;	}&lt;/p&gt;&lt;p&gt;}&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ktk</dc:creator><pubDate>Sun, 02 Aug 2009 11:25:01 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-12805715</link><description>&lt;p&gt;Inside the switch case program is it possible to access another program? how?  &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Akila</dc:creator><pubDate>Fri, 17 Jul 2009 05:37:32 -0000</pubDate></item><item><title>Re: Java switch/case statement syntax</title><link>http://www.tech-recipes.com/rx/668/java-switchcase-statement-syntax/#comment-11075768</link><description>&lt;p&gt;Im a new learner of java. This example of switch case helped me to understand the syntax clearly. The program also provided more knowledge.  I will visit this site whenever i get doubt.Thanks. Good work.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Irene</dc:creator><pubDate>Thu, 18 Jun 2009 00:57:41 -0000</pubDate></item></channel></rss>