There are a number of ways to create apps for Android devices, but the recommended method for most developers is to write native apps using Java and the Android SDK. Java for Android apps is both similar and quite different from other types of Java applications.
Programming languages, like regular languages, are different ways to communicate to a computer how you want it to act. Programming languages allow us to instruct a computer step-by-step how to manipulate data, collect input from users, and display things on a screen, among other things.
Way down on a microscopic level, the processor of a computer sends electrical signals back and forth that control how it operates. High level programming languages like Java mean that we can write these instructions in an abstract manner using words and symbols, and the computer will take care of translating these instructions that we can understand all the way down to electrical impulses that the processor can understand.
A method is a section of code that we can call from elsewhere in our code, and the method will perform some action or return some kind of result that we can use. Methods are used to organize our code into reusable (and understandable) chunks that save us a lot of time and energy.
The second word in the method is the data type that will be returned. In this case the method will return a number, or int. If the method will run some code but not return any kind of data, then the keyword void is used instead of a data type.
Directly after the name we see two parenthesis with nothing in between them. The parenthesis are required, but when empty like this it means we do not pass any data or variables when we call the method. If one or more variables (with data types) were included between the parenthesis, then we would need to pass in appropriate values or variables inside the parenthesis when we call this method.
Line 1 ends with an opening curly brace, and a matching closing curly brace is on line 5. In Java, blocks of code, like the code that make up a method, are often surrounded by curly braces to designate all the code that should be run. In this case it means that all the lines of code between the curly braces will be run each time we call the length() method.
In this case the length() method calculates a value of 11 and returns it to this code where it was called from. We do something with the return value by storing it in a new int variable named textLength.
The basics of Java are crystal clear in the above blog. The basic concepts of the language is same as any other object oriented language. The beauty of the language lies in the platform independence and portability of the language.
Hey Ben, You are a life saver. I have been trying to follow some android app development tutorial and I was completely lost as I have no knowledge of JAVA. After trying to find some resources on google, I landed on this page which made my life much easier to understand what JAVA is all about. You have clearly mentioned the concept of JAVA, which made it much easier for person like me to at least understand the basic. Thanks you very much for putting this out there on the web.
7fc3f7cf58