دورة java للمبتدئين الدرس الخامس عشر
1- تحويل les attributs من public إلى private
//
public class HelloFrench {
private String hello = "bonjour";
}
2- محاولة عرض ل variable hello فل class HelloWorld
//
public class HelloWorld {
public static void main(String[] args) {
HelloFrench helloFrench = new HelloFrench();
System.out.println(helloFrench.hello);
}
}
3- إستعمال ل getters لإسترجاع قيمة ل private
//
public class HelloWorld {
public static void main(String[] args) {
HelloFrench helloFrench = new HelloFrench();
System.out.println(helloFrench.getHello());
}
}
4- إستعمال ل getters لإسترجاع قيمة ل private تتمة
//
public class HelloWorld {
public static void main(String[] args) {
HelloFrench helloFrench = new HelloFrench();
System.out.println(helloFrench.getHello());
}
}