@Override public Hobby copy() { return new Hobby(this); } }
String[] attributes = line2.split(";"); // split it at every ";" h=new Hobby(); h.setNume(attributes[1]); h.setDescriere(attributes[2]); h.setNrPers(attributes[3]); h.setElemNecesar(attributes[4]); System.out.println(h.getNume()); for(int j = 0 ; j < listOfHobbies.size();j++) { h=listOfHobbies.get(j); if(p.getId())== h.getId())) p.addHobby(h); ": " + h.getNume() + ", " + h.getNume(); System.out.println(s); bw.write(s);
Hobby h = new Hobby(); h.setId(Integer.parseInt(String.valueOf(id))); h.setHobbyName(name); return h;
public void addEmployees(int a, HashMap<Employee,Hobby> aList) { Scanner obj = new Scanner(System.in); Scanner obj1 = new Scanner(System.in); for(int i =0; i<a ; i++) { Hobby hob = new Hobby(); Employee emp = new Employee(); System.out.println("Enter id of employee:"); int num = obj.nextInt(); emp.setEmployeeId(num); System.out.println("Enter name of employee:"); String str = obj1. nextLine(); emp.setName(str); hob.enterHobby(); hMap.put(emp,hob); } }
@Override protected Hobby _parseValue(String value) { return new Hobby(value); } }
package com.programsji.converter; import org.springframework.core.convert.converter.Converter; import com.programsji.bo.Hobby; public class StringToHobbyConverter implements Converter<String, Hobby> { @Override public Hobby convert(String str) { // I Am Using Fix Hobbies Here, You Can Add Your Own Method to Get // Hobbies By ID Hobby hobby = null; if (str.equals("1")) { hobby = new Hobby(1, "First Hobby"); } else if (str.equals("2")) { hobby = new Hobby(2, "Second Hobby"); } return hobby; } }
System.out.println("Enter name of employee"); String name=sc.next(); System.out.println("Enter hobby"); String hobby=sc.next(); hm.put(new Employee(name),new Hobby(hobby));
/** * <p> * Adds a hobby that the person actively engages in. * </p> * <p> * <b>Property name:</b> {@code HOBBY}<br> * <b>Supported versions:</b> {@code 4.0} * </p> * @param hobby the hobby to add (e.g. "photography") * @return the property object that was created * @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a> */ public Hobby addHobby(String hobby) { Hobby type = new Hobby(hobby); addHobby(type); return type; }
Hobby h = new Hobby((String)element); return h;