Follow our Telegram channel to get notified instantly whenever new books are published.
Getting Started With Java Using Eclipse – Bernhard Steppan

Pa- rameters are values that the program passes after the method name inside a pair of paren- theses (lines 10, 14, 18, and 22). Since parameters must be declared, parameter passing also always follows the scheme data type identifier, as in a declaration. In line 10 you can see that the class Person takes the parameter address. Then the program overwrites the internal value of the attribute of the same name with this.salutation = salu- tation.
Because setter methods return none values, such methods are marked in Java with the keyword void. The keyword expresses that the return value is empty. In this way, setter methods are easily distinguished from getter methods, which must define the data type of the return value at this point. They are equally easy to distinguish from constructors, which must not define anything at this point.
12.7.2 Usage Listing 12.16 shows the use of setter methods using the example of the program SetterDe- mo. The program creates a new person object named lukas using the default constructor. In lines 9 through 11, the program calls the setter methods of the person class to pass the object the desired values for the lukas object.
Listing 12.16: The setter methods of the class »Person« //Examples/Methods package programmingcourse; public class SetterDemo { public static void main(String[] arguments) { Person lukas = new Person(); 12 Methods lukas.setSalutation(Salutation.STUDENT); lukas.setFirstName(“Lukas”); lukas.setLastName(“Wittek”); lukas.setUniversity(“University of Mainz”); System.out.println(“Hi, I am ” + lukas.getFirstName() + “.”); System.out.print(“I am ” + lukas.getSalutation()); System.out.println(” at the \n” + lukas.getUniversity() + “.”); } } Figure 12.18 shows what the program outputs.
Hi, I am Lukas. I am student at the University of Mainz. Figure 12.18: Program output of the person object »lukas« with its setter methods. 12.8 Summary In Java, there are several types of methods: constructors create objects, getter and setter methods query and modify values. Operations are structured like functions of a classi- cal programming language.
With these methods one starts for example programs, accom- plishes computations or makes database inquiries. As with variables, Java distinguishes between instance and class methods. Instance meth- ods require an object to be executed. Getter and setter methods are examples of instance methods. In contrast, no object is necessary to execute class methods. They are introduced by the keyword static. The best-known static method is main(…), which is used to start a program. 12.9 Literature Java methods { Constructor } Java provides you with four types of methods: With the help of constructors you create objects.
Getter and setter methods are used to query and modify attributes. Operations are used, for example, to perform calculations. Figure 12.19: Professor Roth summarizes the characteristics of Java methods.
All information, procedures and illustrations contained in this book have been prepared to the best of our knowledge and tested with care. Nevertheless, errors cannot be completely ruled out. For this reason, the information contained in this book is not associated with any obligation or guarantee of any kind. Consequently, the authors and publishers assume no responsibility and will not accept any liability, consequential or otherwise, arising in any way from the use of this program material – or any part thereof.
Likewise, authors and publishers do not guarantee that described procedures etc. are free of third party intellectual property rights. The reproduction of common names, trade names, product designations, etc. in this work does not justify the assumption that such names are to be considered free in the sense of trademark and brand protection legislation and may therefore be used by anyone, even without special identification.
#SJUJTI$BUBMPHVJOHJO1VCMJDBUJPO%BUB “DBUBMPHVFSFDPSEGPSUIJTCPPLJTBWBJMBCMFBUUIF#SJUJTIMJCSBSZ 1SJOU *4#/978-3-89576-561-2 &CPPL *4#/978-3-89576-562-9 This work is protected by copyright. All rights reserved, including those of translation, reprint and reproduction of the book or parts thereof. No part of this work may be reproduced in any form (photocopy, microfilm or any other process), not even for the purpose of teaching – with the exception of the special cases mentioned in §§ 53, 54 URG -, or processed, copied or distributed using electronic systems without the written permission of the publisher. ¥$PQZSJHIU&MFLUPS*OUFSOBUJPOBM.FEJB#7 XXXFMFLUPSDPN 1SFQSFTT1SPEVDUJPO#FSOBSE4UFQQBO &EJUPST”MJOB/FBDTV +BO#VJUJOH Contents Preface ………………………………………………………………………………
XXI Part I Basics ……………………………………………………………………… 1 1 Programming Basics……………………………………………………….. 3 1.1 Introduction ……………………………………………………………………. 3 1.2 The Language of the Machine World…………………………………………… 4 1.3 High-Level Programming Languages ………………………………………….. 5 1.4 Development Environment ……………………………………………………. 7 1.4.1 Compiler………………………………………………………………. 7 1.4.2 Editor………………………………………………………………….. 7 1.4.3 Project Management………………………………………………….. 7 1.5 Runtime Environment …………………………………………………………. 8 1.6 Summary……………………………………………………………………….. 8 1.7 Literature……………………………………………………………………….. 9 1.8 Exercises ………………………………………………………………………..
9 2 Technology Overview ………………………………………………………. 11 2.1 Introduction ……………………………………………………………………. 11 2.2 Overview ……………………………………………………………………….. 12 2.2.1 The Early Days of Java ………………………………………………… 12 2.2.2 The Growth Period of Java…………………………………………….. 13 2.2.3 The Presence And Future of Java ……………………………………… 14 2.3 Why Java? ………………………………………………………………………. 15 2.3.1 Easy to Read…………………………………………………………… 15 2.3.2 Object-Oriented ……………………………………………………….
15 2.3.3 Safe And Robust ………………………………………………………. 15 2.3.4 Very Powerful …………………………………………………………. 16 2.3.5 Universally Useable …………………………………………………… 16 2.3.6 Free of Charge ………………………………………………………… 16 2.3.7 Open Source ………………………………………………………….. 16 2.3.8 Easily Portable ………………………………………………………… 16 2.3.9 Easily E
This is a short excerpt from the opening of “” by Unknown, quoted for review and introduction purposes. All rights belong to the copyright holders.
Book Information
- Unique ID: 41669773e950e0c8
- File Extension: .pdf
- File Size: 44,385,660 bytes (42.329 MB)
- Title: –
- Author: Unknown
- ISBN: 9783895765612, 9783895765629
- Pages: 523
- Language: English (en)
Reading & Word Statistics
- Estimated Reading Time: 593.44 minutes
- Total Words: 118,688
- Total Characters: 774,470
- Average Words per Page: 226.94
- Average Characters per Page: 1480.82
Most Frequent Words
class (1782), java (1612), program (1030), method (739), public (656), name (647), string (628), figure (614), eclipse (534), object (482), listing (467), new (464), system (428), classes (402), person (390), type (379), example (370), variable (364), programming (357), package (331), methods (295), programmingcourse (287), data (285), value (283), programs (282), anna (273), println (271), void (265), development (262), operator (262), main (259), static (251), student (247), line (246), also (241), use (233), environment (231), examples (229), objects (227), types (219), case (219), one (216), int (209), return (208), chapter (206), called (206), robert (205), like (196), using (182), libraries (180), language (179), course (174), two (172), variables (171), constructor (169), used (167), shows (162), robot (160), first (159), file (158), table (157), roth (156), private (155), height (155), import (152), julia (152), access (149), statement (149), following (146), base (145), version (143), operators (141), interface (141), window (139), result (137), different (134), declaration (132), parameter (132), error (131), statements (130), output (129), assignment (128), values (127), see (125), exercises (124), code (121), errors (120), project (118), create (118), exception (115), overview (115), start (113), part (110), number (110), block (107), arguments (107), runtime (104), call (104), getname (104), state (102).
