Thursday, May 21, 2020

How Static Fields in Java Work

There can be times when its useful to have values that are shared across all instances of a particular class. Static fields and static constants enable this type of sharing by belonging to the class and not to the actual objects. The Static Modifier Normally fields and methods defined in a class can be used only when an object of that class type has been created. For example, consider a simple Item class that keeps track of goods in a store: public class Item {   Ã‚  private String itemName;   Ã‚  public Item(String itemName)   Ã‚  {   Ã‚  Ã‚  Ã‚  this.itemName itemName;   Ã‚  }   Ã‚  public String getItemName()   Ã‚  {   Ã‚  Ã‚  Ã‚  return itemName;   Ã‚  } } To be able to use the getItemName() method, we must first create an Item object, in this case, catFood: public class StaticExample {   Ã‚  public static void main(String[] args) {   Ã‚  Ã‚  Ã‚  Item catFood new Item(Whiskas);   Ã‚  Ã‚  Ã‚  System.out.println(catFood.getItemName());   Ã‚  } } However, if the static modifier is included in a field or method declaration, no instance of the class is required in order to use the field or method — they are  associated with the class and not an individual object. If you look back at the above example, you will see that the static modifier is already being used in the main method declaration: public static void main(String[] args) { The main method is a static method that does not require an object to exist before it can be called. As main() is the starting point for any Java application, there are in fact no objects already in existence to call it. You could, if you felt like having a program that continually calls itself, do this: public class StaticExample {   Ã‚  public static void main(String[] args) {   Ã‚  Ã‚  Ã‚  String[] s {random,string};   Ã‚  Ã‚  Ã‚  StaticExample.main(s);   Ã‚  Ã‚  Ã‚  } } Not very useful, but notice how the main() method can be called without an instance of a StaticExample class. What Is a Static Field? Static fields are also known as class fields. They are simply fields that have the static modifier in their declarations. For example, lets go back to the Item class and add a static field: public class Item {   Ã‚  //static field uniqueId   Ã‚  private static int uniqueId 1;   Ã‚  private int itemId;   Ã‚  private String itemName;   Ã‚  public Item(String itemName)   Ã‚  {   Ã‚  Ã‚  Ã‚  this.itemName itemName;   Ã‚  Ã‚  Ã‚  itemId uniqueId;   Ã‚  Ã‚  Ã‚  uniqueId;   Ã‚  } } The fields itemId and itemName are normal non-static fields. When an instance of an Item class is created, these fields will have values that are held inside that object. If another Item object is created, it too will have itemId and itemName fields for storing values. The uniqueId static field, however, holds a value that will be the same across all Item objects. If there are 100 Item objects, there will be 100 instances of the itemId and itemName fields, but only one uniqueId static field. In the above example, uniqueId is used to give each Item object a unique number. This is easy to do if every Item object that is created takes the current value in the uniqueId static field and then increments it by one. The use of a static field means that each object does not need to know about the other objects to get a unique id. This could be useful if you wanted to know the order in which the Item objects were created. What Is a Static Constant? Static constants are exactly like static fields except that their values cannot be changed. In the field declaration, the final and static modifiers are both used. For example, perhaps the Item class should impose a restriction on the length of the itemName. We could create a static constant maxItemNameLength: public class Item {   Ã‚  private static int id 1;   Ã‚  public static final int maxItemNameLength 20;   Ã‚  private int itemId;   Ã‚  private String itemName;   Ã‚  public Item(String itemName)   Ã‚  {   Ã‚  Ã‚  Ã‚  if (itemName.length() maxItemNameLength)   Ã‚  Ã‚  Ã‚  {   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  this.itemName itemName.substring(0,20);   Ã‚  Ã‚  Ã‚  }   Ã‚  Ã‚  Ã‚  else   Ã‚  Ã‚  Ã‚  {   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  this.itemName itemName;   Ã‚  Ã‚  Ã‚  }   Ã‚  Ã‚  Ã‚  itemId id;   Ã‚  Ã‚  Ã‚  id;   Ã‚  } } As with static fields, static constants are associated with the class rather than an individual object: public class StaticExample {   Ã‚  public static void main(String[] args) {   Ã‚  Ã‚  Ã‚  Item catFood new Item(Whiskas);   Ã‚  Ã‚  Ã‚  System.out.println(catFood.getItemName());   Ã‚  Ã‚  Ã‚  System.out.println(Item.maxItemNameLength);   Ã‚  Ã‚  Ã‚  } } There are two important things to notice about the maxItemNameLength static constant: It is declared as a public field. Generally its a bad idea to make a field public in any class you design but in this case, it doesnt matter. The value of the constant cannot be changed.The static constant is used from the class name Item, not an Item object. Static constants can be seen throughout the Java API. For example, the integer wrapper class has two that store the maximum and minimum values an int data type can have: System.out.println(The max value for int is: Integer.MAX_VALUE); System.out.println(The min value for int is: Integer.MIN_VALUE); Output: The max value for int is: 2147483647 The min value for int is: -2147483648

Wednesday, May 6, 2020

Friendship Between Horatio And Hamlet - 1000 Words

One will be hardpressed to find true friendship and loyalty in Shakespeare’s masterpieces, especially in his tragedies. Various characters seem to be close friends with the main character in the beginning of plays but usually reveal their true opinions on them or disappear because of their lack of loyalty. The third type of friendship, according to Aristotle, is based on goodness, in which the individuals admire their friend’s goodness and in which they help one another in their pursuit for happiness. The friendship between Horatio and Hamlet lasts longer because the two of them love each other in accordance with their merit. In Shakespeare’s Hamlet, the characters spend a lot of time betraying one another for their own gain. Characters†¦show more content†¦The second instance is when Hamlet tells Horatio that he will fight Laertes, son of Polonius, who Hamlet killed earlier in the play. Horatio loves Hamlet so much, but he is governed by a more sensible disposition, which compels him to speak the truth to his friend, despite the fact that Hamlet never listens to Horatios warnings. In fact, there is only a single point in the play at which Horatio loses his sensible outlook, and it is but a momentary loss. At the end of the play, when Hamlet is killed in his fight with Laertes, Horatio, in his grief, offers to kill himself with his own sword. It is Hamlets dying request that Horatio tell Hamlets story, and let the truth of it be known, that keeps him from doing so. Horatios sense of loyalty to, and love for, his friend, has won out and brought him back to himself and his own, more grounded , sensibility. In a sense, the friendship between Hamlet and Horatio seems to be one-sided. Horatio is constantly doing things that would support and please Hamlet. Horatio is the only person in the play who Hamlet trusts. Horatio is one of the two people who know for certain that Hamlet’s madness is an act. Horatio is also the one person Hamlet confides in personally. Considering his conflicts with his family, Horatio is the only â€Å"family† Hamlet has. Here, the word â€Å"family† is emphasizing the fact that Horatio is the only one taking care of him at the time.Show MoreRelatedFriendship Between Hamlet And Horatio1330 Words   |  6 Pagesfind true friendship and loyalty in Shakespeare’s masterpieces, especially in his tragedies. Various characters seem to be close friends with the main character in the beginning of plays but usually reveal their true opinions on them or disappear because of their lack of loyalty. The friendship between Horatio and Hamlet lasts lo nger because the two of them love each other in accordance with their merit. There are three types of friendship, according to Aristotle. The first type of friendship based onRead MoreDifferent Types Of Friendship By Aristotle1178 Words   |  5 PagesThere are three types of friendship, according to Aristotle. The first type of friendship based on utility. In this type of friendship, both individuals get some sort of benefit from their friend. The second type of friendship is based on pleasure. Here, both individuals are drawn to the other’s personality, appearance, and/or other qualities. The third and final type of friendship is based on goodness, in which the individuals admire their friend’s goodness and in which they help one another inRead MoreTwo Kinds Of Friendship By Aristotle1219 Words   |  5 PagesThere are three kinds of friendship, according to Aristotle. The first type of friendship based on utility. In this type of friendship, both individuals get some sort of benefit from their friend. The second type of friendship is based on pleasure. Here, both individuals are drawn to the other’s personality, looks, or other pleasant qualities. The third and final type of friendship is based on goodness, in which the individuals admire their friend’s goodness and in which they help one another inRead MoreEssay on Literary Analysis of Shakespeares Hamlet1159 Words   |  5 PagesHamlet by Shakespeare is a very wonderfully written book that contains so many literary elements and motifs throughout it that it is still one of the most debated and talked about pieces of literature ever written. It begins with a very mysterious opening that sets the pace for the rest of the book. The old king of Denmark has died and he has returned as a ghost to inform his son, who is also named Hamlet, of the terrible misfortune that has befallen him and left Denmark in a political and emotionalRead MoreEssay on The Perfect Friend; A Character Review of Horatio1343 Words   |  6 Pages4:9-12. This type of friendship is h ard to come by. In the world renowned play written by Shakespeare entitled, Hamlet, Prince of Denmark this exact friendship is demonstrated throughout the play. The play is about a prince that returns to the castle to attend his father’s funeral only to discover his mother has remarried to the king’s brother in a very short time. The ghost of Hamlet’s father led to Hamlet displaying acts of insanity which is kept in check by his loyal friend Horatio. Most people haveRead MoreHamlet: Critical Essay1115 Words   |  5 Pageshave you come to understand about the intense human relationships of Hamlet? How has this understanding been affected by the perspectives of others? In you response you should focus on 3 scenes in the play and a range of perspectives. The intense human relationships of Hamlet have been viewed through numerous perspectives yet all have reached the same conclusions. With the exception of just one, the friendship of Hamlet and Horatio, all the relationships are dishonourable, dysfunctional and destinedRead MoreEssay about Horatio and Laertes as Foils in Hamlet1119 Words   |  5 Pagesnbsp; Horatio and Laertes as Foils in Hamletnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; nbsp; Hamlet, Prince of Denmark by William Shakespeare is a play about a mans revenge for his fathers murder and all the tragedy that comes along with it. The play takes us through the emotions and doubts Prince Hamlet finds within himself after speaking with the presumed ghost of his father, the former King of Denmark.nbsp; Through Hamlet we meet Horatio, a friend of Hamlets and a fellow student.nbsp;Read MoreFriendship And Relationships In Hamlet919 Words   |  4 Pageslessons learned. William Shakespeare’s Hamlet, is not considered a classic without good reason. The play touches upon a wide variety of topics, teaching the reader a great deal about life. Shakespeare provides wonderful insight into everything from friendships to death. Of all the stories taught in British Literature, Hamlet is certainly the most important piece to keep due to the lessons in presents. It is definitely an understatement to say that friendships and relationships are complicated andRead MoreHamlet, By William Shakespeare1413 Words   |  6 PagesWilliam Shakespeare’s play Hamlet focuses on Hamlet, a 30-year old man who tries to seek revenge for his father. Reading the play and looking at it through a contemporary lenses, one can assume the title character is homosexual. Even though Shakespeare does not mean for hamlet to be a homosexual, a contemporary reader can assume this argument; through Hamlet’s characterization and misogynistic relations. Hamlet social aspects has an apparent fluctuation, ever since he encountered his father’s ghostRead MoreFriendships : Themes Relationships In William Shakespeares Hamlet1273 Words   |  6 PagesRelationships Hamlet has many relationships which shape the outcome of the story. The key alliances become the way the stories told. The link between Rosencrantz and Guildenstern help shape the way hamlets friendship with them ends. Not every relationship will work out. If some of the friendships did not go wrong then there would not be an exciting play to watch. The relationships also help bring the story line of the play. The play revolves around alliances of characters. Hamlet does not trust

A Better Place for a Factory Free Essays

After taking every possible factor into consideration, Vietnam is chosen as a better alternative to build a factory instead of Croatia and Botswana. The purpose of this report is to explain the reasons why Vietnam is an advisable choice, the selection of international direct investment as entry mode, as well as the risk assessment and management. When it comes to the investment in Vietnam, the obvious reason first come to people’s mind is cheap labour, but in this report, a deep analysis of Vietnam will be done by adopting PESTEL, which analyse from the perspectives of political spect, economic aspect, social aspect, technological aspect, environmental aspect, as well as legal aspect, the result turn out Vietnam is more feasible for mobile phone manufacture than another two countries. We will write a custom essay sample on A Better Place for a Factory or any similar topic only for you Order Now As to the selection of entry mode, direct investment will be the primary alternative for Vietnam, because most factors in the eclectic theory of Dunning can be settled in Vietnam. Further assessment and solution to the probable risks will also be given. To put it into a nutshell, the research demonstrates the background and advantages of Vietnam as a destination to build actory, together with the decision of entry mode and risk management. Introduction Vietnam, a country which occupies an area of 329,000 square kilometres, locates in the southeast part of Asia. 3/4 of its territory is distributed with mountain and plateau. The number of its population is 86,160,000. As a developing country, its economy is developing rapidly. It maintains trade relationship with more than 150 countries around the global. Because of its astonishing economic growth, numerous enterprises are getting interested in establishing business in this country. Vietnam has for some years now been aggressively expanding its national nfrastructure and growing its subscriber bases across all market segments. All kinds of industries are booming here, including mobile phone manufacturing industry. At the same time, increasing amount of international factories is entering the market and gain sustainable success. Therefore, it would be a wise choice to set a manufacturing point in this country. Full analysis in Vietnam Political reasons As is known, Vietnam is a communist country. The government made a wise decision to establish a plan, which is called doi moi, which is also called â€Å"open door policy’. In order to develop the economic and attract foreign investment, the plan includes abolishing official price controls, devaluing the Dong to the prevailing market rate and so on (Embassy of the United States, 2005). Since the open door policy has been implemented, Vietnam has experienced a rapid growth, also poverty in Vietnam decreased dramatically. The government ot Vietnam is continuing to make changes to maintain the pace of growth and encourage foreign investment. They set an award, called â€Å"Golden Dragon Awards†, to honour enterprises funded by foreign investment. According to Press Release, in 2005, they adopted the Provincial Competitiveness Index (PCI) to rank every province’s business-friendliness to compare the provinces equally. There are indications that the Vietnam’s government is wise and welcomes foreign investment. Economic reasons After various changes have been taken, Vietnam’s GDP is rising dramatically and reached $121. billion in 2011(The World Bank, 2011), and its foreign investment is rapidly increasing too. As GDP growing, Vietnamese citizens’ incomes are increasing. On November 7, 2006, Vietnam was officially recognized by the international ommunity as the 1 50th WTO member, which means Vietnam will be bound by the international rules of law in regards to trade, the market potential is substantial and US firms can benefit from these. Investors of America believe that Vietnam would become the next â€Å"Asian Tiger. † More than $3 billion investment flowed into Vietnam after Vietnam and America re-established diplomatic relations. Vietnam is Asia’s second fastest growing economy after China, and Vietnam will become the world’s 17th largest economy by 2025 (S. Karmel, 2008). Vietnam also has abundant natural resources, so it is good place for manufacturing business. Factory investment continues to pour into Vietnam, even faster than China and India (fgurel) Figurel Social reasons In Vietnam, more than 95% of the population can write and read. English has been the second language in Vietnam and is taught at the high school level, which means training workers is much easier than in Botswana. The population aged 65 and over accounted for only 5. %, and the labour force accounted for 60% of the total population, with an average age of only 24. 5 years old. Low cost for skilled workers is the main reason why we choose Vietnam, while Chinese wages are still less than $1 n hour, factory workers in Vietnam earn as little as $50 a month for a 48-hour workweek, including Saturdays(Clemen, 2006). Technologic al reasons According to National Trade Estimate Report (2012), the new test and assembly plant is being built in Ho Chi Minh City and will be completed in 2013, employing more than 2,400 workers eventually. For example, in Vietnam, Nike has been employing more than 150,000 people since 2002. When Intel’s factories finished, Vietnam will have a high-tech manufacturing factory, except clothing and footwear assembly. Other recent high-tech firms include Fujitsu, Canon and Toshiba. Our factory will get benefits from this. Environmental reasons It isobvious that in the situation of global economic integration, phones are not made by one factory, and most components of phones are come from different countries. Screens usually come from South Korea and chips come from Taiwan, while the flash memory mostly comes from Japan. Vietnam is close to these countries, and Shipping from Vietnam to America is 7% to 9% cheaper than from its neighbours. Finally, infrastructure within Vietnam continues to improve to support developing industries. The road network has increased in quality and more than doubled in length since Electricity is available in all urban areas and in 88% ot rural households, and improved water supplies are accessible to 49% of the population, up 23% from 1993 (The World Bank). Investments in infrastructure accounts for 10% of Vietnam’s GDP in 2010, this high level investment will continually improve infrastructures of Vietnam. Legal reasons Mr. Shu (2010), the chief financial officer of Texhong, said, â€Å"Communism means more stability, it is a common view among Asian executives. † At least a few American executives agree, although they never say so on the record. In order to maintain social security, Vietnamese government does not encourage employees to strike, they take labour disputes and strikes seriously, often take the initiative and come forward to deal with them, hoping that both employers and employees are properly handled to avoid large-scale strikeo Vietnam formulated the â€Å"Foreign Investment Law† in 1987, the law includes: In Vietnam, co-operation enterprise can be carried out in cooperation with a foreign-owned enterprise or establishing a new foreign-owned enterprise; for the companies engaged in mechanical and electronic parts roduction, there is a five-year exemption from the production of raw materials, supplies, spare parts import tax. In order to attract more investment for foreign investors, Vietnamese government requires the local government to simplify and reduce unnecessary procedures, and also seriously deal with corruption. Mode of Entry International direct investment is recommended as a mode of entry in th is report. The definition of direct investment is that a country invests into another country establishing operations or getting tangible assets, including risks in other businesses (Maitena Ducel, Banco de Espana, 2003). Reasons why we choose this mode of entry is based on the eclectic theory of (Dunning, 1993), which will be analyzed in detail in the following part. Three aspects can affect a company’s decision regarding entry mode, namely, ownership, location, and internalization. 1 . Ownership advantages From the perspective of ownership, we use international direct investment as the mode of entry to Vietnam is reasonable. The first factor that should be taken into consideration is that our company owns the whole technology of mobile phone manufacturing and the patent of phones are belong to us, so there is no need to use oint venture, which may cause profits and technology outflow. Phone’s remarkable achievement is a good example. Furthermore, compare with Vietnam, our company owns relatively mature and advanced management skills in this area, so if we do not choose direct investment as the mode of entry, it will bring unnecessary contradiction and difference of opinions to us when we make decisions about the management of our phone factory. 2. Location advantages In Dunning’s theory, he suggested that the location is the key point when we use direct investment. Due to the high cost of human resource of the United States, anufacturing industry is no longer competitive in US as before. In contrast, Vietnam owns many advantages. Vietnam is located in the south area of Asia-Pacific region, near Japan, Taiwan and China, which means factory in Vietnam could get in global production cooperation. Asia-Pacific region enjoys a huge potential market, especially China. The world first large population will likely to provide the market for the mobile tlrm set in Vietnam. This market- seeking motive point also comes trom the theory ot Buckley and Casson(Buckley and Casson, 1998). (Vandemoortele, Milo; Bird, Kate, 2010). Besides this factor, the cheap and abundant labour resources are available is another advantage for building factory in Vietnam. Also, the Vietnamese government provides plenty of incentive policy for encouraging foreign direct investment, such as exemption of import tax. Based on these location advantages, we choose international direct investment. 3. Internalization Our firm is based in the United States. With the abundant experience in managing multinational business, the firm is able to internalize the Vietnamese local situation and take the most advantage of all those merits and decrease the cost. By August 2005, Vietnam had 5,618 foreign-investment projects, and with the total capitalization at $49 billion in the country, while the direct investment had reached $3. 2 billion by the end of July 2005(Clemen, 2006). According these data, we believe choosing direct investment as the mode of entry to Vietnam is a reasonable and promising choice. Risk Assessment and Risk Management In spite of the advantages of Vietnam, risks still exist. Risks can be divided into several parts as follow. Environment risk in Vietnam is about its climate change and natural disaster. Like Philippines and Cambodia, Vietnam is a coastal country that requently suffers from catastrophe like Typhoon, storm, earthquake and Tsunami, which may lead to some economic risks. For example, in 2012, the flood in Indonesia resulted in the shutdown of the hard disks workers and then led to upward price in hard drives globally. This may happen in Vietnam, too. However, this risk can be prevented if handled before the disaster happens. For instance, the company can consult experts of geology to find a proper position to build factories (upland or dry area). And the building materials should be chosen carefully to stand against those isasters, for example, reinforced concrete. The structure of building also need to be paid attention to, earthquake proof and storm proof construction would be a smart choice. Apart from the environmental risk, technological risks also exist. Although economy is developing rapidly in Vietnam with the gradually mature infrastructure system, it still confronted with some problems, including delayed port and other infrastructure, and depends heavily on its neighbour countries for transhipments. Eric Johnson, American Shipper, 2013)However, this sort of risk can be handled in nother way. The US mobile manufacturing firm can set the plants in the manufacturing district where infrastructure is relatively mature. In this case, the risk can be avoided. Furthermore, geopolitical risks should be considered in this report. As mentioned above in the analysis of mode of entry, Vietnam is one of the world’s four remaining single-party socialist states, and it is highly government oriented in terms of culture and medium. ( Vuong, Q. H. ; Dam, V. N,Van Houtte, D. ; and Tran, T. D. Dec. 2011). This may result in corruption in the company. Regarding the risk of the ompany, the following advice can be put forward. First of all, transparency of the company’s management should be improved, which includes holding stockholders’ meeting at regular intervals, selecting the representatives of the staffs. Additionally, supervising and monitoring system should be improved in the company. W more, election of the leaders of the company should be honest, fair and regularly. In addition, in terms of societal risks, the income inequality leads to regular strike in Vietnam. Like China, Vietnam does not offer complete tranquillity either. For instance, workers re becoming more vocal and staging more strikes, despite a government ban on independent unions. Nearly 20,000 workers walked out this spring at a Nike shoe factory run by a Taiwanese contractor. Only when given a 10 percent raise to $55 a month and the workers went back to work. In this case, it is not difficult to find an appropriate solution. Firstly, make sure the rest time of the staff. Specifically, two days weekend and 8 hour’s working hours should be guaranteed, with overtime offered diploid salary. Secondly, incentive and encouragement in public shall be given to stimulate the motivation of the staff. Thirdly, company managers should keep in track of the thoughts of the staffs, how they are satisfied with their working situation, what they need etc. Fourthly, improving the welfare of the workers, for example, providing adequate subsidiaries and health insurance will help to reassure the public. Conclusion To sum up, choosing Vietnam as the destination of mobile phone manufactory is more advantageous than Croatia and Botswana, which means fewer obstacles, more opportunities, more support, and more resources. Though it comes along with some risks, they can be avoided by many effective measures. How to cite A Better Place for a Factory, Papers