Monday, December 30, 2019

Using the Switch Statement for Multiple Choices in Java

If your Java program needs to make a choice between two or three actions, an if, then, else statement will suffice. However, the if, then, else statement begins to feel cumbersome when there are a number of choices a program might need to make. There are only so many else...if statements you want to add before the code begins to look untidy. When a decision across multiple options is required, use the switch statement. The Switch Statement A switch statement allows a program the ability to compare the value of an expression to a list of alternative values. For example, imagine you had a drop-down menu that contained the numbers 1 to 4. Depending on which number is chosen, you want your program to do something different: //lets say the user picks number 4int menuChoice 4;switch (menuChoice){ case 1: JOptionPane.showMessageDialog(null, You chose number 1.); break; case 2: JOptionPane.showMessageDialog(null, You chose number 2.); break; case 3: JOptionPane.showMessageDialog(null, You chose number 3.); break; //This option gets chosen because the value 4 matches the value of //the menuChoise variablecase 4:  JOptionPane.showMessageDialog(null, You chose number 4.);  break; default: JOptionPane.showMessageDialog(null, Something went wrong!); break;} If you look at the syntax of the switch statement you should notice a few things: 1. The variable containing the value that needs to be compared to is placed at the top, inside the brackets. 2. Each alternative option starts with a case label. The value to be compared against the top variable comes next, followed by a colon. For example, case 1: is the case label followed by the value 1 — it could just as easily be case 123: or case -9:. You can have as many alternative options as you need. 3. If you look at the above syntax, the fourth alternative option is highlighted — the case label, the code it executes (i.e., the JOptionPane) and a break statement. The break statement signals the end of the code that needs to be executed. If you look, youll see that every alternative option ends with a break statement. Its very important to remember to put in the break statement. Consider the following code: //lets say the user picks number 1int menuChoice 1;switch (menuChoice)case 1: JOptionPane.showMessageDialog(null, You chose number 1.);case 2: JOptionPane.showMessageDialog(null, You chose number 2.);break;case 3: JOptionPane.showMessageDialog(null, You chose number 3.); break;case 4: JOptionPane.showMessageDialog(null, You chose number 4.); break;default: JOptionPane.showMessageDialog(null, Something went wrong!); break;} What you expect to happen is to see a dialog box saying You chose number 1, but because there is no break statement matching the first case label, the code in the second case label also gets executed. This means the next dialog box saying You chose number 2 will also appear. 4. There is a default label at the bottom of the switch statement. This is like a safety net in case none of the values of the case labels match the value being compared with it. Its very useful to provide a way of executing code when none of the desired options are chosen. If you always expect one of the other options to be chosen, then you can leave out the default label, but to put one at the end of every switch statement you create is a good habit to get into. It might seem unlikely that it will ever be used but mistakes can creep into the code and it can help to catch an error. Since JDK 7 One of the changes to the Java syntax with the release of JDK 7 is the ability to use Strings in switch statements. Being able to compare String values in a switch statement can be very handy: String name Bob;switch (name.toLowerCase()){ case joe: JOptionPane.showMessageDialog(null, Good morning, Joe!); break; case michael: JOptionPane.showMessageDialog(null, Hows it going, Michael?); break; case bob: JOptionPane.showMessageDialog(null, Bob, my old friend!); break; case billy: JOptionPane.showMessageDialog(null, Afternoon Billy, hows the kids?); break; default: JOptionPane.showMessageDialog(null, Pleased to meet you, John Doe.); break;} When comparing two String values, it can be a lot easier if you make sure they are all in the same case. Using the .toLowerCase method means all the case label values can be in lowercase. Things to Remember About the Switch Statement †¢ The type of the variable to be compared against must be a char, byte, short, int, Character, Byte, Short, Integer, String, or enum type. †¢ The value next to the case label cannot be a variable. It has to be a constant expression (e.g., an int literal, a char literal). †¢ The values of the constant expressions across all the case labels must be different. The following would result in a compile-time error: switch (menuChoice){ case 323: JOptionPane.showMessageDialog(null, You chose option 1.); break; case 323: JOptionPane.showMessageDialog(null, You chose option 2.); break; †¢ There can only be one default label in a switch statement. †¢ When using an object for the switch statement (e.g., String, Integer, Character) make sure it is not null. A null object will result in a runtime error when the switch statement is executed.

Sunday, December 22, 2019

Anti-Semitic German Propaganda - 708 Words

During World War II, anti-Semitic publications circulating throughout Germany display clear evidence of pervading the minds of young German children. Julius Steicher, editor of Der Stumer and the agent responsible for many of the anti-Semitic publications (Mills), helped dramatically initiate the German resistance toward Jews early on in a child’s life. It is important to understand the severity of anti-Semitism taught to the future Nazi generation in order to maintain the National Socialist state and further it’s agenda. By examining the ideas, and publications aimed towards children that express those ideals, it is clear that the National Socialist state wanted to indoctrinate a hateful, militant agenda into young children. Ultimately, the final result was to maintain the prejudice view that the Jewish people were the inferior race, and therefore the enemy for future generations. One of the chief ways to target young German children with Nazi propaganda was through the school systems. A German educator wrote in The National Socialist Essence of Education, that mathematics was â€Å"Aryan spiritual property, an expression of the Nordic fighting spirit, of the Nordic struggle for the supremacy in the world†(Hirsch, 119). Children were given slogans to learn and recite such as: â€Å"Judas the Jew betrayed Jesus the German to the Jews† (Mann, 90). Furthermore, by 1937, about 97% of all teachers belonged to the National Socialist Teachers Union (Mills). Established in 1929, the UnionShow MoreRelated Holocaust Essay789 Words   |  4 Pages What does the term â€Å"propaganda† say, what does one think of, when approached with this term? Would one think it was of a positive of negative connotation? What about the association it had with the holocaust, would it then be considered negative? Did the Nazis use the role of propaganda overtly? Propaganda played an extremely crucial part in the Nazi’s rise of power, the brainwashing of the Germans to hating and ultimately killing the Jews. What is being discussed is the power of persuasion andRead MoreNazi Propaganda and The Holocaust Essay1047 Words   |  5 PagesNazi propaganda played an important role in the Holocaust, the extermination of millions based on race, religion, and ethnicity. It successfully secured the acquiescence of the general public to the crimes committed by the Nazis. The Nazi Party used their control of the media to fuel anti-Semitic belief and to persuade Germans to support the Nazi cause throughout the Holocaust and World War II. Although the Nazis were the largest political party in Germay, they did not win a majority of votes inRead MoreEssay on Causes of the Holocaust980 Words   |  4 Pagesreasons are; for centuries Germany had been an anti-Semitic country Jews were used as scapegoats for German problems. Also centuries of Nazi persecution caused the Holocaust in particular 1933 -1939 as well as Adolf Hitler and his racist views which influenced thousands of Germans. The Main reason for the holocaust happening was that Germany had been anti-Semitic for many centuries, and during those centuries the anti-Semitism had gradually got worse. Therefore becauseRead MoreSection I. How Did Adolf Hitler Use Environmental Isolationism1607 Words   |  7 Pagesmilitaristic power, maintain and strengthen his control over Germany during The Third Reich, and easily purge Germany of â€Å"Impure races† with his anti-semitic raised soldiers. Hitler used environmental isolationism to train and gain loyalty from the youth while he manipulated and indoctrinated them to follow his beliefs using propaganda and anti-semitic teachings. Hitler isolated the youth from the rest of Germany to be able to easily manipulate their beliefs. In 1926 the Hitler Youth was foundedRead MoreNazi Propaganda During World War II1448 Words   |  6 PagesOne of the most crucial aspects of Nazi propaganda in Germany during World War II was indoctrinating the youth. One of Hitler’s main beliefs was that the children of Germany were the future of the country. Therefore, he created several propaganda movements to influence the children, so Hitler could gain their trust. Nazi propaganda was extremely effective in manipulating the feelings and opinions of German citizens. The Nazi movement attracted the youth in an extremely enticing way which attractedRead MoreNegative Propaganda Essay1421 Words   |  6 PagesPropaganda is a form of communication, a way to influence on the attitude of a community toward some position or cause. The propaganda in its origins was neutral; nevertheless, it had been used to manipulate. For this reaso n, the propaganda also can be defined as information that is deliberately expressed in order to harm or hurt a person. The deliberate spreading of such information lead to persuasion, persuading to do things that are not the regular scheme of a person which may result affectedRead MoreHow Did Adolf Hitler Use Environmental Isolationism In1617 Words   |  7 Pagesmilitaristic power, maintain and strengthen his control over Germany during The Third Reich, and easily purge Germany of â€Å"Impure races† with his anti-semitic raised soldiers. Hitler used environmental isolationism to train and gain loyalty from the youth while he manipulated and indoctrinated them to follow his beliefs using propaganda and anti-semitic teachings. Hitler isolated the youth from the rest of Germany to be able to easily manipulate their beliefs. In 1926 the Hitler Youth was foundedRead MoreThe Holocaust : A More Perfect Union1060 Words   |  5 Pageshistory, few acknowledge its underlying causes. Historians often attribute the combination of German aggression and foreign appeasement with the Nazi rise to power and success in completing the Final Solution. However, the power of the totalitarian regime originated from its domestic policy, allowing one man to manipulate the thoughts and actions of an entire nation. The Nazi indoctrination of Germany with propaganda provided the government with the political power necessary to unleash police terror uponRead MoreThe Jews And The Jewish Population760 Words   |  4 Pagesthat Jewish people were not to be trusted stating that they were disgusting people so that the younger German’s would grow up with hatred for the Jew’s. Germany was willing to do everything they possi bly could for all Germans to have hate along with despise for the Jew’s. The propaganda campaign was started and became very successful, it encouraged passivity and hate for the Jewish population. Scapegoating was caused as the Jewish population was being blamed and receiving negative treatment after beingRead MoreThe Nazi Party s Inner Circle Essay1538 Words   |  7 Pagesinside all of us†, but instead that Germans in the 1930s and 1940s were not what Browning would call â€Å"ordinary men†. Goldhagen’s thesis rides on his assertion that, at this point in time, the German public were inherently anti-Semitic, and that Hitler’s eliminationist rhetoric was simply the spark that ignited what was already inevitable, due to the views of the majority of Germans. If Goldhagen’s work is a more accurate description of the true motivations of the German people of the time, it would undermine

Saturday, December 14, 2019

Islam in Southeast Asia Free Essays

In the 11th century, a turbulent period occurred in the history of Malay Archipelago, the Chola Navy crossed the ocean and attacked the Srivijaya kingdom of Sangrama Vijayatungavarman, Kadaram (Kedah), an important fortified city in the Malayan peninsula was sacked and the king was taken captive. Soon after that, the king of Kedah Phra Ong Mahawangsa became the first ruler to abandon the traditional Hindu faith, and converted to Islam with the Sultanate of Kedah established in year 1136. Samudera Pasai converted to Islam in the year 1267, and many other rulers follow suit. We will write a custom essay sample on Islam in Southeast Asia or any similar topic only for you Order Now There are several theories to the Islamization process in Southeast Asia. The first theory is trade. The expansion of trade among West Asia, India and Southeast Asia helped the spread of the religion as Muslim traders brought Islam to the region. The second theory is the role of missionaries or Sufis. The Sufi missionaries played a significant role in spreading the faith by syncretising Islamic ideas with existing local beliefs and religious notions. Finally, the ruling classes embraced Islam which further aided the permeation of the religion throughout the region. The ruler of the region’s most important port, Malacca Sultanate, embraced Islam in the 15th century, heralding a period of accelerated conversion of Islam throughout the region as the religion provided a unifying force among the ruling and trading classes. ( Do?n nay e k bi?t co nen d? th? nay khong, vi no la 2 gi? thuy?t nen nghe no c? k tin c?y). Islam in Indonesia. As we know, Islam is the dominant religion in Indonesia, but not many people know that the amount of Muslims in Indonesia is larger than anywhere else in the world, with approximately 202. 9 million identified as Muslim (88. 2% of the total population) as of 2009. To foreign observers as well as to many Indonesians themselves, Indonesian Islam has always appeared to be very different from Islam at most other places, especially from the way it is practised in the Arabian peninsula. The religious attitudes of the Indonesians, it was often said, were more influenced by the Indian religions (Hinduism, Buddhism) that had long been established in the Archipelago and the even older indigenous religions with their ancestor cults and veneration of earth gods and a plethora of spirits. Many contemporary Indonesian Muslims refuse to recognise them as Islamic because they conflict with modern conceptions of (universal) Islam. In many cases, however, they came to Indonesia as part of Muslim civilisation, even if they did not perhaps belong to the core of Muslim religion. They represent an earlier wave of Islamisation. Islam In Malaysia Malaysia is a multiconfessional country with Islam being the largest practiced religion, comprising approximately 61. 4% Muslim adherents, or around 17 million people. In the 11th century, a turbulent period occurred in the history of Malay Archipelago, the Chola Navy crossed the ocean and attacked the Srivijaya kingdom of Sangrama Vijayatungavarman, Kadaram (Kedah), an important fortified city in the Malayan peninsula was sacked and the king was taken captive. Soon after that, the king of Kedah Phra Ong Mahawangsa became the first ruler to abandon the traditional Hindu faith, and converted to Islam with the Sultanate of Kedah established in year 1136. Samudera Pasai converted to Islam in the year 1267, and many other rulers follow suit. The local population saw that Islam could extricate them from this bondage and provide the means for the extirpation of social evils. The new religion gave the small man a sense of this individual worth – the dignity of man – as a member of an Islamic community. Originally, the draft Constitution of Malaysia did not specify any official religion for the state. This move was supported by the rulers of the nine Malay states, who felt that it was sufficient that Islam was the official religion of each of their individual states. However, Justice Hakim Abdul Hamid of the Reid Commission which drafted the Constitution came out strongly in favour of making Islam the official religion, and as a result the final Constitution named Islam as the official religion of Malaysia. Islam in the Malay Archipelago in general and Malaysia in particular follows the Shafi Madhab (school of thought). However there are many Muslims in Malaysia who do not follow any particular school. In Perlis, the state constitution specifies that Perlis follows the Qur’an and Sunnah and not a particular madhab. Many Muslims in Perlis therefore do not follow any madhab, as is the case with the followers and members of the Muhammadiyah Organisation in Indonesia. Source: http://en.wikipedia.org/wiki/Islam_in_Southeast_Asia http://en.wikipedia.org/wiki/Spread_of_Islam_in_Southeast_Asia http://en.wikipedia.org/wiki/Islam_in_Indonesia http://en.wikipedia.org/wiki/Islam_in_Malaysia Global and Local in Indonesian Islam  by Prof. Martin Van Bruinessen,  Southeast Asian Studies (Kyoto)  vol. 37, no. 2 (1999), 46-63. http://www.islamcan.com/islamic-history/islam-in-malaysia.shtml How to cite Islam in Southeast Asia, Papers

Friday, December 6, 2019

Einstein Essay Fellow Man Example For Students

Einstein Essay Fellow Man Einsteins Brain Markedly different from normThe article that I have read is about how Albert Einsteins gray matter in his brain has differences then the average persons. They are not sure though if it has any links between his great intelligence though. Dr. Dahlia W. Zaidel of UCLA was the researcher on this project. She started out by investigating to see if the brain of a genius might show special features. She then examined two slides made from Einsteins brain after his death in 1955. The slides contained samples of his hippocampus. She then compared Einsteins brain with tissue from ten individuals of ordinary intelligence from the ages of 22 to 84 qt their time of death. Einsteins neurons on the left side of the brain were consistently larger then those on the right side. Dr. Zaidel noted that these marking were much different from those seen in the other brain of people with normal intelligence. She noted, that the neurons in the left hippocampus imply that Einsteins brain may have had stronger nerve cell connections between the hippocampus and the neocortex than his right. She noted that The neocortex is where detailed, logical, analytical and innovated thinking takes place.With the difference in the size of the neurons are unknown, whether they occurred at birth during development or as an abnormality. She said also that she didnt know if this asymmetry is related to his genius or not. At the end it said that normal brain tissue is usually available for study but there is no brain bank for geniuses. She does hope in the future to obtain tissue from very bright scientists, which would make it possible to place Einsteins brain of genius. I thought this research article was very interesting. That would be really interesting if they could find out how and why Einstein was so smart. It would be really neat to see.