Java Programming for Kids, Parents and Grandparents by Yakov Fain

By Yakov Fain

Show description

Read or Download Java Programming for Kids, Parents and Grandparents PDF

Best programming: programming languages books

Objektorientierte Programmiersprache C++: Vollständige Einführung anhand von Beispielen (VDI-Buch) (German Edition)

In diesem Werk werden alle Aspekte der Sprache C++ behandelt, deshalb ist das Buch ebenso für Einsteiger, mit oder ohne Vorkenntnisse über eine andere Programmiersprache, als auch für Umsteiger von anderen Programmiersprachen bzw. C-Programmierer geeignet. Die Darstellung der Sachverhalte erfolgt knapp und systematisch, die Beispiele sind kurz, prägnant und compiler- unabhängig und auf allen Rechnern mit C++ 2.

Extra resources for Java Programming for Kids, Parents and Grandparents

Example text

But Java classes can not have two separate parents. If this would happen with people, kids would not be subclasses of their parents, but all the boys would descendents of Adam, and all the girls descendents of Eve J. Not all pets can dive, but fish certainly can. Let’s add a new method dive() to the class Fish now. println("I'm at " + currentDepth + " feet below sea level"); return currentDepth; } } The method dive() has an argument howDeep that tells the fish how deep it should go. We’ve also declared a class variable currentDepth that will store and update the current depth every time you call the method dive().

Sometimes people forget why they have written the program this way. The other reason for writing comments is to help other programmers understand you code. Program Comments There are three different types of comments: • If your comment fits in one line, start it with two slashes: // This method calculates the distance • Longer multi-line comments have to be surrounded with these symbols: /* and */, for example: /* the next 3 lines store the current position of the Fish. */ • Java comes with a special program javadoc that can extract all comments from your programs into a separate help file.

In Java the sign for a logical or is one ore two vertical bars. It works like this – if any of the two conditions is true, result of the entire expression is true. In the following examples I use use a variable of type String. equals("California")) The difference between the two is that if you use two bars, and the first expression is true, the second expression won’t even be checked. If you place just a single bar, JVM will evaluate both expressions. The logical and is represented by one or two ampersands (&&) and the whole expression is true if every part of it is true.

Download PDF sample

Rated 4.27 of 5 – based on 42 votes