public class First { @Resource Second second ; public First(){ second = new Second(); } public String doSecond(){ return second.doSecond(); } }
this.second = new Second(schedule.getSecond()); this.minute = new Minute(schedule.getMinute()); this.hour = new Hour(schedule.getHour());
switch(v.getId()) { case R.id.button1: Second s = new Second(); //add this fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(android.R.id.content, s); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); break; }
public void aMethod(Result result) { s = new Second(); result.val = s; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Calling the method from Second Class myotherclass = new Second(this); // <----- this myotherclass.toast_method(); }
public class First { private Second s; public First() { } public void aMethod() { s = new Second(); } public Second getSecond(){ return s; } }
public Main (Second second) { this.second = new Second (this); }
Second secondFragment = new Second(); getFragmentManager().beginTransaction() .replace(R.id.frame, secondFragment,"UNIQUE_FRAGMENT_TAG") .addToBackStack("UNIQUE_FRAGMENT_TAG").commit();
Second s = new Second(); setChanged(); notifyObservers(s);
public void test() { a = 1; // have access to inherited protected field or chat(); // methods of base class } public static void main(String[] args) { Second f = new Second(); f.chat(); System.out.println(f.a); }
@Stateless public class ManageSomethingBean implements ManageSomething { @PersistenceContext(unitName="firstDB") private EntityManager firstEM; @PersistenceContext(unitName="secondDB") private EntityManager secondEM; // some annotations public void storeSomething(Object value) { firstEM.persist(new First(value)); secondEM.persist(new Second(value)); } }
import demo.Second; public class First{ Second second=new Second(); void printStuff(){ System.out.println(second.getBar()); } }
//... // static instance private static Second instance = new Second(/* put constructor arguments here, if any */); //... public static Form getForm2() { if (form2 == null) { form2 = new Form("form"); form2.addCommand(getBackCommand()); form2.setCommandListener(instance); // --> replace "this" with "instance" } //...
class Test{ public static void main(String[] args) { Second f = new Second(); f.chat(); System.out.println(f.a); } }
public class First { public static void main(String args[]){ int var = 1; Second Second = new Second(); System.out.println(var); //Prints out 1 var = Second.test(var); System.out.println(var); //Prints out 2 } }
public void mybutton_click() { Second myfragment = new Second(); Bundle bundle = new Bundle(); bundle.putString("value",et1.getText()); myfragment.setArguments(bundle); activity.addFragment(myfragment, false, "Second"); }
Main m = new Main(); Second s = new Second(); m.setSecond(s); s.setMain(m);
... First first = new First(); entityManager.save(first); //<- the id is updated Second second = new Second(); second.setB(300); second.setA(first.getA()); first.setSeconds( new ArrayList()); first.getSeconds().add(second); entityManager.save(second); entityManager.getTransaction().commit();