### oefening 1 ### ### activity_main.xml ### <androidx.constraintlayout.widget...> <TextView ... android:id="@+id/textView1" ... /> </androidx.constraintlayout.widget.ConstraintLayout> ### MainActivity.java ### @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... String varMessage1 = "Java leer je door oefenen"; TextView myTextView = (TextView)findViewById(R.id.textView1); myTextView.setText(varMessage1); ... }
Download hier het bestand.
### oefening 2 ### ### Student.java ### public class Student { String studentNaam; int studentNummer; public Student(String naamStud, int nummerStud){ this.studentNaam = naamStud; this.studentNummer = nummerStud; } public String getStudentNaam(){ return studentNaam; } public int getStudentNummer(){ return studentNummer; } } ### MainActivity.java ### @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Student s = new Student("Jean Luc", 23); // String varMessage1 = "Java leer je door oefenen"; String varMessage1 = s.getStudentNaam(); ... }
Download hier het bestand.
### oefening 3 ### ### MainActivity.xml ### @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Student s = new Student("Jean Luc", 23); // String varMessage1 = "Java leer je door oefenen"; String varMessage1 = s.getStudentNaam(); ... }
Download hier het bestand.