Film izle Sinema izle Bayan Azdirici Bayan Azdirici Damla Azdirici Geciktirici Sprey Geciktirici porno sex travesti cialis kiz oyunlari kiz oyunu oyna porno sex porn sex r57.txt c99 shell hackerbox



Community

October 24, 2010

Train With A Trainee: Week 1 Part F, Switch Cases

Switch case 1

In the last 3 lessons we went through 3 basic codes that gave a print out on your OUTPUT window using variables and conditionals. We can move on now to using Switch Cases.

What is a switch case?  A switch case is used when there are multiple choices that can be chosen. Before we can get into setting up a switch we must talk about a second primitive data type. In the last 3 lessons we stuck with double. To move forward we now must use a different data holder called int. I thought now might be a good time to get a little more technical. Here are the literal definitions of double and int from Oracle.

double: The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in section 4.2.3 of the Java Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency

int: The int data type is a 32-bit signed two’s complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use.

Feel free to follow that link and read up on anything you wish. The more you know the easier it becomes. Since the training hasn’t used any other type of Primitive Data Holders I didn’t want to start confusing you (or myself) until it was necessary.

The only thing we need to know and worry about for right now is that we need to replace double with int. What you will find is that if you do not replace double with int the application will not run. Here’s our sample code.


package learning;

public class learning {

/**

* @param args

*/

public static void main(String[] args)  {

int a =10;

switch (a){

case 10:

System.out.println(“TEN”);

break;

case 15:

System.out.println(“FIFTEEN”);

break;

default:

System.out.println(“Nothing was satisfied”);

break;

}

}

}

Here’s what you are looking at. We replaced the double data holder with int data holder. That line is int a =10; we then followed it up with switch (a){ and then added three separate cases  case 10: case 15: and default: Then we used the command we have been using all week System.out.println(“”) and what we wanted it to PRINT in the OUTPUT window when the case was satisfied.

When we run this application the OUTPUT window will read TEN. Now if we go back to int a =10; and change that variable to int a =15; the OUTPUT window will read FIFTEEN. Finally if we change the int a =15; to int a =20; The application will run through the cases and find that the value 20 is not satisfied by either of the first 2 cases and print the default: phrase in the OUTPUT window.

As you can see since we just changed int a =15; to int a =20; the application ran through the case and since no case matched the variable of 20 it printed the default statement.

This is an example of how we can create multiple choice applications. You can add as many cases as you wish. Now the only thing we haven’t talked about is the break; it is a good practice to insert a break; after each statement but is not a necessity. What the break; does is make sure the application STOPS after the statement is printed and doesn’t keep looking to satisfy its task. That is my basic understanding of break;

Now we have created a simple switch case application.

We will stop there for a little while and let you get familiar with the practice. To help train your brain and fingers add in more cases, change your variable numbers and of course change your OUTPUT statements.

As always these are listed in order HERE on the site as well as HERE in the forums. If you get confused or something doesn’t make sense, don’t hesitate to contact me through this post or in the Forums. I am doing my best to keep up with support for you guys as well.

Happy coding everyone. :0)






 

 










About the Author

Stormy Beach
I worked at T-Mobile for 5 years. I was the go to guy for Android phones and training. That passion didn't stop even after my departure from the company. I currently moved up from my MyTouch 3G to a Samsung Vibrant. A lot has changed in a very short time. I look forward to all the latest and greatest every time I wake up.





 
 

 
Screen Shot 2012-05-18 at 6.19.43 PM

The ManDroid Show: Free the HTC EVO 4G and One X! Lock Up the iPhone!

Thank you as always for clicking into another episode of The ManDroid Show. Apple, I swear, why do you got to make our lives miserable? Try concentrating on make your out dated phone batter. Enjoy the show! News Topics HTC EVO ...
by David Pena
1

 
 
OutSPin_Permissions_Final

OutSpin: Why Google will never get it right!

These have been an interesting two weeks (last week writer’s block did win over me) in the Android/Google world: Samsung presented the Galaxy SIII, Google and Oracle were in court waiting for a decision that could change ...
by Fernando Fonseca
6

 
 
Huawei Prism

[Poll] Are entry level Android devices a step backwards in promoting the Brand?

Here I am, sifting through thousands of stories from around the web trying to find the next cool or big thing that you guys might want to know about. That is when I stumble upon a post over at Tmonews about the Huawei Prism 3G ...
by Stormy Beach
5

 

 
Wii-U-Android

[Rumor] Nintendo’s Wii U could be powered by Android

So, last year at E3, Nintendo announced the successor to the Wii, named the Wii U. Its announcement was met with some excitement and some disappointment from Nintendo fans around the globe. Personally I feel Nintendo took a t...
by Stormy Beach
3

 
 
SlideToUnlock

OutSpin: There’s something wrong with this picture (and other considerations)

Writer’s block sucks and I suffer from it. Not for a lack of things to say – I have literally dozens of ideas during the week – but when it gets to the moment that I have to sit down and translate those ideas ...
by Fernando Fonseca
1

 
 
boeing-android

Boeing makes more than jumbo Jets

Looks like they will let anyone make an Android device now a days. Just kidding. That is the point of an open platform after all. Another big name company, know more for jets that get our poor pathetic butts to events, is looki...
by Stormy Beach
1

 




One Comment


  1. Kasyful Fuadi

    good.. i keep studying here…



Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


 
sexsikislezbiyensex izledeutschsex.netdeutschporno.net sexpornoporn videoshd sexsex free pornfree Porn videos
kiz oyunlari kiz oyunu oyna porno sex porn sex porno