Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Language fundamentals

100% developed
From Wikibooks, open books for an open world
<Java Programming

Java IDEsJava Programming
Language Fundamentals
Statements
NavigateLanguage Fundamentals topic:()
Topics:

The previous chapter"Getting started" was a primer course in the basics of understanding how Java programming works. Throughout the chapter, we tackled a variety of concepts that included:

  • Objects and class definitions;
  • Abstract and data types;
  • Properties;
  • Methods;
  • Class-level and method-level scopes;
  • Keywords; and,
  • Access modifiers, etc.

From this point on, we will be looking into the above mentioned concepts and many more in finer detail with a deeper and richer understanding of how each one of them works. This chapter onLanguage fundamentals introduces the fundamental elements of the Java programming language in detail. The discussions in this chapter will use the concepts we have already gathered from our previous discussions and build upon them in a progressive manner.

The Java programming syntax

[edit |edit source]

Inlinguistics, the wordsyntax (which comes fromAncient Greekσύνταξις whereσύν [syn] means "together", andτάξις [táxis] means "an ordering") refers to "the process of arranging things". It defines the principles and rules for constructing phrases andsentences innatural languages.

When learning a new language, the first step one must take is to learn itsprogramming syntax.Programming syntax is to programming languages whatgrammar is to spoken languages. Therefore, in order to create effective code in the Java programming language, we need to learn its syntax — its principles and rules for constructing valid code statements and expressions.

Java uses a syntax similar to theC programming language and therefore if one learns the Java programming syntax, they automatically would be able to read and write programs in similar languages — C,C++ andC#

The next step one must take when learning a new language is to learn its keywords; by combining the knowledge ofkeywords with an understanding ofsyntax rules, one can createstatements, Programming Blocks, Classes, Interfaces, et al.

Usepackages to avoid name collisions. To hide as much information as possible use theaccess modifiers properly.

Createmethods that do one and if possible only one thing/task. If possible have separate method that changes the object state.

In an object oriented language, programs are run with objects; however, for ease of use and for historic reasons, Java hasprimitive types. Primitive Data Types only store values and have no methods. Primitive Types may be thought of as Raw Data and are usually embedded attributes inside objects or used as local variables in methods. Because primitive types are not subclasses of the object superclass, each type has a Wrapper Class which is a subclass of Object, and can thus be stored in a collection or returned as an object.

Java is a strongtype checking language. There are two concepts regarding types and objects. One is the object type and the other the template/class the object was created from. When an object is created, the template/class is assigned to that object which can not be changed. Types of an object however can be changed by type casting. Types of an object is associated with the object reference that referencing the object and determines what operation can be performed on the object through that object reference. Assigning the value of one object reference to a different type of object reference is called type casting.

The most often used data structure in any language is a character string. For this reason java defines a special object that isString.

To aggregate same type java objects to an array, java has a specialarray object for that. Both java objects and primitive types can be aggregated to arrays.


Java IDEsJava Programming
Language Fundamentals
Statements


Retrieved from "https://en.wikibooks.org/w/index.php?title=Java_Programming/Language_Fundamentals&oldid=3644562"
Category:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp