Đang chuẩn bị liên kết để tải về tài liệu:
Java Programming for absolute beginner- P10

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Java Programming for absolute beginner- P10:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming. | JavaProgAbsBeg-05.qxd 2 25 03 8 51 AM Page 138 k 0 c c 0 2 V 0 a c S S s k a o k Q. S s public void add Test tt tt.x tt.y System.out.println tt.x Now the Test class defines two integer variables x and y. In main you declare a Test object t and set t.x to 1 and t.y to 2. Next you call the add method only this time it accepts a Test object reference instead of two primitive data types as its argument. The reference to t is named tt within the method. You can see that it does the same thing as in the previous example. It adds up two variables values and stores the result in the first variable. The difference here is that these variables belong to the Test object which is referenced by both t outside the method and tt inside the method . When you reassign the tt.x variable the value becomes 3 and is printed. When control returns to main the value of t.x will reflect this change and will be 3 too. It s like when you call the plumber to come and fix your toilet. You don t send him a clone of your toilet you tell him where it is so he can work his magic and when he s done your toilet is fixed. It s the same concept here you tell the method where your object is and then it goes and operates on it and when it s done your object might have changed. Method Overloading Another important parameter-passing concept for you to learn is method overloading. When two methods have the same name but have different types or numbers of arguments the method is overloaded. Methods names are not unique you can have two different methods with the same name that do two different things if their signatures are different. Consider these three methods method accepts two int arguments public void add int a int b a b System.out.println a method accepts three int arguments public void add int a int b int c a b c System.out.println a method accepts two double arguments public void add double a double b a b System.out.println a team Line - live informative Non-cost and Genuine Please purchase PDF .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.