Getting familiar with Java: Working with classes

As we have felt that in order to have the perfect android app we should have familiarity with basic concepts and components of java. We will learn about object orientation programming with the help of Java. Here, we will learn about classes, inheritances, variables and variable scopes. We will learn in depth about array, strings and escape sequences that should be used for some special characters.

While learning basics of Java, we will learn in depth about Google Android development. As we have learnt from the series of Android Studio tutorials we have come to understand that Java is the programming language that is to be used in creating android apps. That is why it is very significant to learn about structure, syntax and different other related aspects of Java so that it should be easier to write apps.

The more good part is that Java is not difficult. It is easy programming language, and there is plenty of resources in and around the internet from where we can take the help from it. Java is simple and in order to learn it we have to learn some basic object orientation concepts and then we can take the full control of its programming.

Java is first developed by Sun Microsystems and it is a high level programming language and later on it was overtaken by Oracle. It is very easy programming languages where every code can be understood in terms of the human mind. Whereas there are other programming languages which solely depend upon machine codes. It is simple, architectural independent, object oriented, portable, distributed, multithreaded, robust, dynamic, and secure and provides high performance in high-level programming languages.

Most of other languages work in a mouthful of the environment and in other environments they do not perform in excellence. While with Java it is portable, robust and platform independent. Java uses virtual machines to run the apps. So, if you have installed virtual machines than it can run the java codes. Everything about java stays with java folder. It uses java compiler to convert the code into a class file. This means code converted into classes. The class is the machine language which is well understood by java virtual machines.

If we use Eclipse editor to write Java code then, the code converted into.Class which becomes the machine language to work with the compiler environment. So, .Class file contains the bytecode which reads machine languages of the java virtual machine (Java VM). This means java coded does not depend upon operating system but it depends upon Java VM and that is why able to run with a different operating system such as Windows, Linux, Mac OS, Android Phones and many other similar software environments.

Then, Java VM depending upon the platforms you use runs the bytecode and then program and that is why it is called as platform independent programming language. Java like most other languages is a case-sensitive language. While typing programming for statement one needs to use the correct case otherwise this could produce errors. Microsoft Visual Editor is not a case-sensitive language. Java uses various forms of dot notation and with single dot notation there are various members of classes with specific fields known as class path or methods.

With Eclipse, when you hit the dot there would be plenty of other suggestions regarding features and others. It is better to learn these features in detail through this feature so that ultimately you could learn in detail about it. The syntax structure of Java is that each statement can have more that one line and that should be ended with a semi-colon. At some point in time, you could find that this is not necessary but one should always follow the rules so that there would not be confusion ahead.

A statement can be written in many lines but the semi colon should be used at the last line of the statement. Group of statements can be considered as the code blocks and these are code blocks with the help of French braces {}in the start and end of the statement this is closed by orange French brackets. In between statement there would be functions and these would be closed by blue French brackets.

The comments inside of the code are the way to document your code so that when you look these series of codes later you could know the exact structure of statements, functions, methods and strings that are included inside codes. You can create single line (//) or multi line comments (/**/) inside java. It helps you to understand the series of codes which you are building upon. This is evident that for multi-line comment one should use a forward slash and asterisk and then to end with an asterisk and backward slash.

You could use built-in JavaDoc comment which begins forward slash and then two asterisk and then one asterisk at the front of dot and then end with one asterisk and backward slash. Java Doc can be compiled with HTML file later on for help and for indication of codlings so that your original source codes can be detected.

Single line comments can be used at the front of a single line with two forward slashes or at the end of existing line with two forward slashes. Java is an example of object orientated model. This is used in reference to design and text elements of an object with a graphical user interface. Here we can learn this in simple terms. Suppose you have a smart phone when it is an object. The characteristics of the phone may have in built career with it, it can be feature phone or smart phone, it can have a touch-sensitive screen or keyboard attached to it.

Apart from this the phone can perform some other tasks like it can call, internet, sms and other tasks. In object-oriented programming, we can create a button in terms of design or code elements. Then many instances can be created inside that button and when we want to change the tasks or instances given to buttons then, we can edit the object to make the change globally. Object does have attributes and you can customize those attributes to work in a certain manner such as input type and visibilities. In term of Java, these are known as properties.

The tasks the phone makers are known as methods such as making a call or sending a SMS. In order to remember exactly what object oriented programming means for Java, the characteristics of a phone would be represented with the state or properties. While the tasks the phone performance can be considered as actions or methods in Java. Suppose you are writing phone operating system code then the phone or the main bulk of the code can be considered as an object and then, you provide the characteristics in the name of properties and assign tasks to properties in the name of methods.

Properties is connected with objects in term of instances. You create instances to any of properties and then connect it and then create different methods for each property to work in seamless manners. When we built anything with Java, we create instances and this can be created innumerable ways so that these can connect with properties to assign the characteristics. In short Properties, is state of the object and methods are the behavior of objects.

Due to presence of object oriented programming the Java makes the entire programming code modular and that makes you to work with the particular tasks on its own. Objects are re-usable and when we make changes to the original objects of the instances that come out automatically take the advantages of these changing objects.

Java object is called as a class. It can have sub-classes. When one class provides its properties and methods to another extended class then it can be called as subclass of that class. It is called as inheritance and this appears most times within android programming environment. In Java, you create objects by creating classes. A class always starts with a capital letter. So, you can identify where the class is by seeing which the capital letter inside statement is.

 

This entry was posted in Java on by .

Modified: 17th Oct 2017

About Mohan Manohar Mekap

Mohan Manohar is a blogger from India who founded Ittech back in 2007. He is passionate about all things tech and knows the Internet and computers like the back of his hand.