|
|
By Java Tutor, on October 27th, 2009
Information in a java program is organized in a specific way. The smallest and simplest java program can only execute if it is coded as a .java file. When a .java file is created, it must contain at least one class. A java class contains specific information such as variables and methods. A single java file is generally structured similarly:
public class Greeting
{
int someVar = 0;
public static void main(String[] args) {
System.out.println(“Hello, world!”);
}
}
In this classic “Hello, world!” output, the class Greeting is defined. A .java file must contain and define at least one class. A class can be controlled by methods defined within it. In this example, a special method main will try to show the output “Hello, world!” when the class is loaded. A class may contain fields such as the integer type of variable declared as someVar, with the value of zero. As each .java file should have one class, it should also have one class that has the main method. Greeting, someVar, and main are called identifiers. An identifier labels entities in a java program such as a class, a variable, or a method. The class Greeting is a public class. Each java file can have many classes but only one can be declared public. Note also that the method main is public, and static.
Many .java files may be actually needed to run a more complex program. Similarly, some methods and classes are meant to be reused in some other way for various programming applications. In this case, it is best to organize .java files according to their use, and group programs that generally work for the same kind of output. If a greetprogram.java file contains:
Continue reading Java File Structure
By Java Tutor, on October 22nd, 2009
A java program can be created using simple text editors such as the ubiquitous Notepad in Windows or TextEdit in Macs. Such programs are called editors. Editors cannot execute the programming code written on them. They are simply means of storing the program for future execution. There are other computer software that can be used to specifically aid a java developer to create and edit and manage complex and elaborate codes and algorithms. These programs offer a variety of features, to help a Java programmer organize their codes and files. A java program is a file with the “.java” extension (i.e. myJavaProgram.java). A Java program requires compilation using a program called a Java compiler. What a Java compiler does is to interpret the human-readable code written in the .java file and covert it to a file in bytecode. Basically, the human-readable instructions typed in a .java file are called a source code.
By using a java compiler, these instructions are converted and stored in bytes. Each of the class included in a java source code are separately encoded to a corresponding class file. For example, a .java file defining two classes- myClass and myOtherClass will compile into two files in bytecode, with the names myClass.class and myOtherClass.class, respectively. Files saved as .class lose their human readability, but are more compact and easier to distribute. However, there are ways to reverse engineer .class files back to a human-readable source code. Reverting bytecoded files back to its source code can be done by using decompilers. Decompilers themselves are not meant to steal the original codes of a program. As such, care and ethical concerns should always be considered when attempting to reverse engineer and extract information from someone else’s hard work.
Continue reading Using Java, Defining and Running Java Programs
By Java Tutor, on October 21st, 2009
Java is a computer language that was primarily designed to be simple and also architecturally neutral. During its early years, the language was promising but at that time there was still no market for it. In 1995, what the developers did was to introduce Java at the Sun World exhibition. Programmers were enthusiastic about the simple language and the richness of its library. This meant that more and more portable programs could be written that could bypass proprietary operating systems.
Java offers micro and enterprise editions of its library which make the programmers comfortable on any hardware. There is a vast range of this from simple gaming devices to the largest internet providers. In this article, what would be focused on would be the benefits of Java’s superior performance and its security features.
Java programs are grouped to a portable intermediate form that we know now as byte codes. This is similar but of a newer form of the machine-language instructions. Java Virtual Machine has a program that could be used so as to interpret these portable byte-code commands. Make-up and form of Java programs meant that they process at a higher speed compared to scripts and programs which are written in interpreted languages. The only problem here is that they are somewhat slower than C and C++ programs.
Continue reading Security and Performance – key benefits of Java
By Java Tutor, on October 20th, 2009
The memory size is a significant aspect in the development of embedded systems. Programmers try to reduce the size of the generated compilation of codes through the use of compiler optimization techniques. This method is known as procedural abstraction.
Procedural abstraction is mainly used for optimizing code size. In the process, the repetitive instances of similar code fragments are grouped into new subroutines. During the early methods of programming, procedural abstraction is used on the primitive levels of the machine code in optimizing linkers and binary rewriting tools. A procedure is used to compile codes. It then provides an interface for the code through a formal parameter list and a mechanism for transferring parameters.
There are two types of procedural abstraction. Abstraction by parametrization skips the identification of the provided actual parameters used in the calling procedure. On the other hand, the specification technique provides abstraction from details of implementation of a procedure. Since a procedure has its unique piece of code with well-defined entry and exit points, a specification can be created for the specified code. A code specification defines the functions of the procedure without giving the details of how the procedure is implemented.
Continue reading Procedural abstraction
By Java Tutor, on October 8th, 2009
Java is one of the commonly used object-oriented programming languages. It is developed specifically for creating distributed programs on shared networks and on the World Wide Web.
Programming is often seen as the integration of logical statements, not as the process of defining data. The concept used in object-oriented programming is about focusing on the objects to be manipulated rather than the logic to be applied in the process. The objects involved in the object-oriented programming range from human beings (defined by name, address, and so forth) to locations (whose properties can be specifically defined and managed) and even tools that you use on your computer (such as navigation bars and action buttons). In a program using the object-oriented approach, the procedures are logically arranged to take input data, apply the definite process and then produce a data output.
Continue reading Object Oriented Approach
|
|