private void setData() { ArrayList<Country> countryList = new ArrayList<>(); //Add countries countryList.add(new Country("1", "India")); countryList.add(new Country("2", "USA")); countryList.add(new Country("3", "China")); countryList.add(new Country("4", "UK")); //fill data in spinner ArrayAdapter<Country> adapter = new ArrayAdapter<Country>(context, android.R.layout.simple_spinner_dropdown_item, countryList); spinner_country.setAdapter(adapter); spinner_country.setSelection(adapter.getPosition(myItem));//Optional to set the selected item. }
public class Context { private final static Context instance = new Context(); public static Context getInstance() { return instance; } private Country country = new Country(); public Country currentCountry() { return country; } }
countryInfo[count] = new Country(); // **** add countryInfo[count].setName(name); countryInfo[count].setCapital(capital); countryInfo[count].setRegion(region); countryInfo[count].setRegionNum(region_Nbr); countryInfo[count].setPopulation(capital_population); inputString = br1.readLine();
public class User { ... @PrePersist public void prePersist() { if (country == null) { country = new Country("US"); } }
public void addCountry(String name, String capital, int population) { countries[nextFreeCountry] = new Country(name,capital,population); nextFreeCountry++; }
public void addCountry(String name, String capital, int population) { countries[nextFreeCountry] = new Country(name, capital, population); nextFreeCountry++; }
var myList= (List<Country>())CommonLogic.GetAllCountries(); myList.Add(new Country() {Id = -1, Name= "None selected" }); myList= liste.OrderBy(p => p.Id).ToList(); ViewData["countries"] = myList;
Map<String, Country> countries = new HashMap<String, Country>(); Country country; //...loop to read the file... country = countries.get(team); if (country == null) { country = new Country(); } //add information to country countries.put(team, country); //...end loop...
String[] name = new String[] {"united_state", "united_kingdom", "france", "germany", "canada"}; List<Country> countries = new ArrayList<Country>(); for(int i = 0; i < name.length; i++) { countries.add(new Country(name[i])); }
ArrayList<Country> countryList = new ArrayList<Country>(); Country country = new Country("AFG","Afghanistan",false); countryList.add(country); ...
MyDAO mockDAO = mock(MyDAO.class); List<Country> countries = Arrays.asList(new Country(...)); when(mockDAO.getCountries()).thenReturn(countries); when(mockDAO.getCities((Country) any(Country.class))).thenThrow(new NetworkIsDownException()); MyService underTest = new MyService(mockDAO); // TODO call underTest.getRandomCityList() and check that it does what it should do.
private void LoadCountries() { Countries = new ArrayList<Country>(); ArrayList<String> citiesAustralia = new ArrayList<String>( Arrays.asList("Brisbane", "Hobart", "Melbourne", "Sydney")); Countries.add(new Country("Australia", citiesAustralia)); ArrayList<String> citiesChina = new ArrayList<String>( Arrays.asList("Beijing", "Chuzhou", "Dongguan", "Shangzhou")); Countries.add(new Country("China", citiesChina)); adapter = new CountryAdapter(getActivity(), Countries); expandableListView.setAdapter(adapter); }
Country country = new Country(); country.setId(countryId); Query query = em.createQuery("update City set country = :country where id = :cityId"); query.setParameter("country", country); query.setParameter("cityId", cityId); query.executeUpdate();
Country c = new Country(); //created a new country object but not have an id Province p = new Province(); gen.addCountry(); //if this method returns a country object it will have an id. gen.addProvince(c); gen.addCity(p);
Product p = ...; Country es = new Country(); es.setID( CountryId.ES ); p.getCountry().add( es );
for (Locale locale : locales) { try { String iso = locale.getISO3Country(); String code = locale.getCountry(); String name = locale.getDisplayCountry(); if (!"".equals(iso) && !"".equals(code) && !"".equals(name)) { countries.add(new Country(iso, code, name)); } catch (MissingResourceException e){ //do nothing } }
String[] locales = Locale.getISOCountries(); List<Country> countries = new ArrayList<>(); int i = 32000007; for (String countryCode : locales) { Locale obj = new Locale("", countryCode); countries.add(new Country(i, obj.getDisplayCountry(Locale.ENGLISH))); i++; }
ArrayList<Country> listCountry = new ArrayList<>(); Country objCountry = new Country(); objCountry.setCountryID(1); objCountry.setCountryName("India"); listCountry.add(objCountry);
Country germany = new Country("Germany"); City berlin = new City("Berlin"); City Hamburg = new City("Hamburg"); berlin.country = germany; hamburg.country = germany; germany.cities = new HashSet<>(asList(berlin, hamburg)); germany.saveOrUpdate(); // or whichever definition you use