AsegGasiaBlog

Android Development - Why Is It Still Exciting? - Gear Up

Android Development <="click"

Why Is It Still Exciting?

Gear Up

Let’s Java
Writing Android applications is fairly easy, while writing code, in general, is easier said than done.
But since you are already here, developing in Android is going to be simple for you because its default language is Java.

Android applications are written in Java, but not the full-blown version of Java.
Only a subset of the Java libraries that are most useful on Android is used. This smaller subset of Java excludes classes that aren’t suitable for mobile devices.
Even if you don’t have too much experience with Java, this course will take you closer to your first App, one step at a time.

You may recall that a Java program is defined as a collection of objects that communicate by invoking each other's methods.
Here are the four keywords that you must commit to your memory. Click any keyword to view its details.
Objects
Classes
Methods
Instance Variables


Which of the following statements is/ are true for the relation between objects, classes, methods, and instance variables?
Select one or more answers
An object is an instance of a class.
A class can contain many methods.
A method contains its unique set of instance variables.
A method and class are the same thing.

Let’s do a quick rehash of what you must remember about the Basic Syntax of Java.
Firstly, Java is case sensitive. To a computer, t is not T.
If the variable you sent (TreeCount) is really named treeCount, the program won’t work.
 // These are completely different variables!
int treeCount = 15;
int TreeCount = 25;
This can frustrate a human, but the computer doesn't care so watch out.

For all Class Names, the first letter should be in uppercase.
If several words are used to form the name of the class, then each word's first letter should be in uppercase.
For example, we can have a Tree class:
 public class Tree {
    //Tree class
    public void showMsg() {
        System.out.println("Tree Here");
    }
}


You can create an instance of this class.
Remember that Variables are typically lowercase, while classes are uppercase.
Therefore, using the same name for BOTH class and instance variable actually helps us differentiate.
 public static void main(String[] args) {
    Tree tree = new Tree();
    tree.showMsg();
}

All Method Names should start with a lowercase letter.
If several words are used to form the name of the method, then each word after the first word should have the first letter as upper case.
For example, the following method takes in a variable and does some math.
 public int addTwoNumbers(int firstNumber, int secondNumber) {
    int sum = firstNumber + secondNumber;
    return sum;
}

The Program File Name should exactly match the class name. When saving the file, you should save it using the class name.
 public int add2Numbers(int firstNumber, int secondNumber) {
    int sum = firstNumber + secondNumber;
    return sum;
}
The file can be saved as the file as Number.java (.java is the file extension and Number is the name of the class used)



______________can be used to find out what class the method belongs to.
Tap the correct answer to fill in the blanks

findClass
(findClass)
getClass( )
(getClass)


getClass( )
Correct Answer
Awesome! getClass( ) can be used to find out what class the method belongs to. This class is defined in the object class and is available to all objects.
Proceed


Java Runtime Benefit

But you must wonder, “What makes Java special?”
The Java programming language is one of the glorious tools that make programming for Android a breeze as compared with programming for other mobile platforms.
Other languages insist that you manage memory, allocate and deallocate bytes, and then shift bits around like a game of dominoes.
On the contrary, Java runtime allows you to focus on writing code by using a clean, understandable programming language instead of focusing on the “plumbing” just to get the screens to show up.


XML Programming


Although the Android operating system consists primarily of Java code, some of the framework isn’t written in Java.
Android apps use small amounts of XML in addition to Java.
All the UI and layout of your app are designed using XML. That is, it helps you to design your app in terms of how it will look, how components like buttons, textview, etc. will be placed and their styling.

An XML document exhibits a tree structure.
It has one (and only one) root element, and the elements are properly nested. XML documents are text-based, human readable, and are meant to be self-describing.

Here is an example of an XML document for a bookstore:
 <?xml version="1.0" encoding="UTF-8"?>
<!-- bookstore.xml -->
<bookstore>
    <book ISBN="0123456001">
        <title>Java For Dummies</title>
        <author>Tan Ah Teck</author>
        <category>Programming</category>
        <year>2009</year>
        <edition>7</edition>
        <price>19.99</price>
    </book>
</bookstore>
In the above example, <bookstore> is the root element. It has one child element <book>, which in turn has several children (<title>, <author>, <category>, etc).

Which of the following statements is true for the naming conventions in Java programming?
Select one or more answers
All Class Names start with an uppercase letter
All Method Names should start with a lowercase letter
All Program File Names start with a .

 Why Is It Still Exciting?

Android Development <="click"

Popular Posts