Here is a report on Android Operating System, devices, market share, etc. up to May 2016.
Have a look at the video for the same.
[youtube=https://www.youtube.com/watch?v=MJQCCy0CNdM]
Here is a report on Android Operating System, devices, market share, etc. up to May 2016.
Have a look at the video for the same.
[youtube=https://www.youtube.com/watch?v=MJQCCy0CNdM]
Objectives :
Parameter |
Parcelable | Serializable |
What is it? | Google developped Parcelable for better performance on android | Serializable is a standard Java interface |
Purpose | For marshaling and unmarshaling Java objects | For marshaling and unmarshaling Java objects |
Package | android.os | java.io |
Speed | 10 times Faster than Serializable because it is optimized for usage on android development | Slower than Parcelable |
Implementation Time | Requires more time than Serializable | Requires very less time as compared to Parcelable |
Degree of Implementation | Difficult | Easier than Parcelable |
Memory | Less temporary objects | Serializable interface create a lot of temporary objects and cause quite a bit of garbage collection |
Use with Intent | Parcelable array can be pass via Intent in android |
Cannot be used with Intent |
Objectives :
Subscribe blog for more updates.
Objectives :
NetBeans IDE is having a new and great feature where we can full screen the code editor window.
This small video tutorial shows how to change editor full screen in NetBeans IDE?
[youtube=”https://www.youtube.com/watch?v=w49znamwczw&feature=youtu.be”]
Being a trainer, I need to share screen with code and sometime only code nothing else. This is one of the most useful feature for me while teaching Java technologies and UI technologies such as HTML5, CSS, JS, etc. This is why I love NetBeans IDE a lot.
Hope this tutorial is helpful for you as well.
Objectives :
[sourcecode lang=”java”]
import java.util.Scanner;
public class DecimalToHexadecimal {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter decimal number you like: ");
int deci = input.nextInt();
System.out.println("The hexadecimal number for decimal "
+ deci + " is " + convert(deci));
}
public static String convert(int decimal) {
String hex = "";
while (decimal != 0) {
int hexValue = decimal % 16;
hex = toHexadecimal(hexValue) + hex;
decimal = decimal / 16;
}
return hex;
}
public static char toHexadecimal(int hexValue) {
if (hexValue <= 9 && hexValue >= 0) {
return (char) (hexValue + ‘0’);
} else {
return (char) (hexValue – 10 + ‘A’);
}
}
}
[/sourcecode]
Output :
Enter decimal number you like: 1234
The hexadecimal number for decimal 1234 is 4D2
Objectives :
Program :
[sourcecode lang=”java”]
import java.util.Scanner;
public class DecimalToRoman {
private static String toRoman(int num) {
String[] romanCharacters = { "M", "CM", "D", "C", "XC", "L", "X", "IX", "V", "I" };
int[] romanValues = { 1000, 900, 500, 100, 90, 50, 10, 9, 5, 1 };
String result = "";
for (int i = 0; i < romanValues.length; i++) {
int numberInPlace = num / romanValues[i];
if (numberInPlace == 0) continue;
result += numberInPlace == 4 && i > 0? romanCharacters[i] + romanCharacters[i – 1]:
new String(new char[numberInPlace]).replace("\0",romanCharacters[i]);
num = num % romanValues[i];
}
return result;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number : ");
int decimal = scanner.nextInt();
System.out.println(toRoman(decimal));
}
}
[/sourcecode]
Output :
Enter a number : 1234
MCCXXXIV
[sourcecode lang=”java”]
public class DecimalToRoman {
private static String toRoman(int num) {
String[] romanCharacters = { "M", "CM", "D", "C", "XC", "L", "X", "IX", "V", "I" };
int[] romanValues = { 1000, 900, 500, 100, 90, 50, 10, 9, 5, 1 };
String result = "";
for (int i = 0; i < romanValues.length; i++) {
int numberInPlace = num / romanValues[i];
if (numberInPlace == 0) continue;
result += numberInPlace == 4 && i > 0? romanCharacters[i] + romanCharacters[i – 1]:
new String(new char[numberInPlace]).replace("\0",romanCharacters[i]);
num = num % romanValues[i];
}
return result;
}
public static void main(String[] args) {
if(args.length<1 || args.length>1){
System.out.println("Wrong input");
}else{
String number = args[0];
int decimal = Integer.parseInt(number);
System.out.println(toRoman(decimal));
}
}
}
[/sourcecode]
Particulars | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B |
Processor Chipset | Broadcom BCM2837 64Bit Quad Core Processor powered Single Board Computer running at 1.2GHz | Broadcom BCM2836 32Bit Quad Core Processor powered Single Board Computer running at 900MHz |
Processor Speed | QUAD Core @1.2 GHz | QUAD Core @900 MHz |
RAM | 1GB SDRAM @ 400 MHz | 1GB SDRAM @ 400 MHz |
Storage | MicroSD | MicroSD |
USB 2.0 | 4x USB Ports | 4x USB Ports |
Max Power Draw/voltage | 2.5A @ 5V | 1.8A @ 5V |
GPIO | 40 pin | 40 pin |
Ethernet Port | Yes | Yes |
WiFi | Built in | No |
Bluetooth LE | Built in | No |
Visit here for Raspberry Pi Training
Objective :
ActivityOne.java
[sourcecode lang=”java”]
String value = "Hello!";
Intent in = new Intent(this,ActivityTwo.class);
in.putExtra("Key", value);
startActivity(in);
[/sourcecode]
ActivityTwo.java
[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived = bundle .getString("Key");
[/sourcecode]
ActivityOne.java
[sourcecode lang=”java”]
String value1 = "Hello!";
String value2 = "Hi!";
Intent in = new Intent(this,ActivityTwo.class);
in.putExtra("Key1", value1);
in.putExtra("Key2", value2);
startActivity(in);
[/sourcecode]
ActivityTwo.java
[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived1 = bundle .getString("Key1");
String valueReceived2 = bundle .getString("Key2");
[/sourcecode]
ActivityOne.java
[sourcecode lang=”java”]
String value1 = "Hello!";
String value2 = "Hi!";
Intent in = new Intent(this,ActivityTwo.class);
Bundle bundle = new Bundle();
bundle.putString("Key1", value1);
bundle.putString("Key2", value2);
in.putExtras(bundle);
startActivity(in);
[/sourcecode]
ActivityTwo.java
[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived1 = bundle .getString("Key1");
String valueReceived2 = bundle .getString("Key2");
[/sourcecode]
ActivityOne.java
[sourcecode lang=”java”]
String[] array = new String[]{"Item1", "Item2", "item3", "Item4", "item5"};
Intent in = new Intent(this,ActivityTwo.class);
Bundle bundle = new Bundle();
bundle.putStringArray("MyArray", array);
in.putExtras(bundle);
startActivity(in);
[/sourcecode]
ActivityTwo.java
[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String arrayReceived[] = bundle.getStringArray("MyArray");
[/sourcecode]
ActivityOne.java
[sourcecode lang=”java”]
ArrayList<String> array = new ArrayList<String>();
array.add("Hello");
array.add("Hi");
array.add("Bye");
Intent intent = new Intent(this, ActivityTwo.class);
intent.putExtra("array_list", array);
startActivity(intent);
[/sourcecode]
ActivityTwo.java
[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
ArrayList<String> array = (ArrayList<String>) bundle.getStringArrayList("array_list");
[/sourcecode]
Have fun with Intent.
Objectives :
Java Program :
[sourcecode lang=”java”]
import java.util.Scanner;
public class BinaryToDecimal {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter binary number: ");
String binary = scanner.nextLine();
int decimal = binaryToDecimal(binary);
System.out.println("Decimal equivalent of "+ binary +" is "+ decimal);
}
private static int binaryToDecimal(String binary) {
final int base = 2;
int decimal = 0;
for (int i = 0; i < binary.length(); i++) {
if (binary.charAt(i) == ‘0’) {
decimal += 0 * Math.pow(base, binary.length() – i – 1);
} else if (binary.charAt(i) == ‘1’) {
decimal += 1 * Math.pow(base, binary.length() – i – 1);
} else {
System.out.println("Invalid Binary Number");
System.out.println("Binary Number Contains only 0’s or 1’s");
System.exit(0);
}
}
return decimal;
}
}
[/sourcecode]
Output :
Enter binary number: 1110
Decimal equivalent of 1110 is 14
Objectives :
Java Program to convert Decimal to Binary :
[sourcecode lang=”java”]
public class DecimalToBinary {
public void toBinary(int number){
int binary[] = new int[25];
int n = 0;
// Convert Decimal to Binary
while(number > 0){
binary[n++] = number%2;
number = number/2;
}
// Print Binary number
for(int i = n-1;i >= 0;i–){
System.out.print(binary[i]);
}
}
public static void main(String[] args){
DecimalToBinary obj = new DecimalToBinary();
obj.toBinary(14);
}
}
[/sourcecode]
Output :
1110
Java Program to convert Decimal to Binary using Scanner class :
[sourcecode lang=”java”]
import java.util.Scanner;
public class DecimalToBinary {
public void toBinary(int number){
int binary[] = new int[14];
int n = 0;
// Convert Decimal to Binary
while(number > 0){
binary[n++] = number%2;
number = number/2;
}
// Print Binary Number
for(int i = n-1;i >= 0;i–){
System.out.print(binary[i]);
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int num= scanner.nextInt();
DecimalToBinary obj = new DecimalToBinary();
obj.toBinary(num);
}
}
[/sourcecode]
Output :
Enter a number: 14
1110