Atul Palandurkar

Raspberry Pi 3 VS Raspberry Pi 2

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

Passing data between activities in Android

Objective :

  • Passing data between activities in Android
  • Passing multiple data between activities in Android
  • Passing array between activities in Android
  • Passing ArrayList between activities in Android
  • Passing ArrayList to another activity in Android
  • Sending data via Intent in Android
  • Sending multiple data via Intent in Android
  • Sending array between activities in Android
  • Sending ArrayList between activities in Android
  • Sending ArrayList to another activity in Android
  • Sending data via Intent and Bundle in Android
  • Sending multiple data via Intent and Bundle in Android
  • Passing array between activities in Android using Intent and Bundle
  • How to pass array to another activity in Android?
  • How to pass array between activities in Android?
  • How to pass data to another activity in Android?
  • How to pass data to activity in Android?
  • How to pass data to between activities in Android?
  • How to pass ArrayList to another activity in Android?
  • How to pass ArrayList between activities in Android?

 

Code for passing data between activities in Android :

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]

 

Code for passing multiple data or values between activities in Android :

Method 1 : Using Intent to pass data and Bundle to extract data between activities in Android

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]

 

Method 2 : Using Bundle to pass and to extract data between activities in Android

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]

 

Code for passing array between activities in Android :

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]

 

Code for passing ArrayList between activities in Android :

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.

Java Program to find prime number upto N number

Objectives :

  • Write a Java program to find prime number upto N number
  • Write a Java program to print prime number upto N number
  • Write a Java program to find prime number upto N number using Command Line Arguments
  • Write a Java Program to find prime number upto N number via Command Line Arguments
  • Write a Java program to find prime number upto N number using Scanner class

 

Java Program / Code :

Method 1 : Java Program to find Prime Number upto N number using Scanner class

[sourcecode lang=”Java”]

import java.util.Scanner;
class PrimeNumber
{
public static void main(String[] args)
{
int n,p;
Scanner s=new Scanner(System.in);
System.out.println(“Enter number : ”);
n=s.nextInt();
for(int i=2;i<n;i++)
{
p=0;
for(int j=2;j<i;j++)
{
if(i%j==0)
p=1;
}
if(p==0){
System.out.println(i);
}
}
}
}
[/sourcecode]

Method 2 : Java Program to find Prime Number upto N number using Scanner class and writing function to find prime number

Method isPrime() for checking if a number is prime or not

[sourcecode lang=”java”]
public class PrimeNumber{
public boolean isPrime(int num) {
if ( num < 2 ){
return false;
}
for (int i = 2; i <= Math.sqrt(num); i++) {
if ( num % i == 0 ) {
return false;
}
}
return true;
}
}

// Mock Test Class to test above code
import java.util.Scanner;

public class Demo
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);

System.out.println("Please enter a number: ");
int num = scanner.nextInt();

if ( num < 2 ) {
System.out.println("\n There are no Prime Numbers available");
System.exit(0);
}
System.out.println("\n Prime Numbers from 1 to "+ num);
PrimeNumber primeNum = new PrimeNumber();

for (int i = 3; i <= num; i++) {
if ( primeNum.isPrime(i) ) {
System.out.print(", " + i);
}
}
}
}
[/sourcecode]

Method 3 : Java Program to find Prime Number upto N number using Command line input

[sourcecode lang=”Java”]

class PrimeNumber
{
public static void main(String[] args)
{
int n,p;
n=Integer.parseint(args[0]);
for(int i=2;i&lt;n;i++)
{
p=0;
for(int j=2;j&lt;i;j++)
{
if(i%j==0)
p=1;
}
if(p==0){
System.out.println(i);
}
}
}
}
[/sourcecode]

Steps to run above program via command line :

  1. Compilation : C:\JavaPrograms>javac PrimeNumber.java
  2. Interpretation : C:\JavaPrograms>java PrimeNumber 20

Output :

2

3

5

7

11

13

17

19

Program to find Sum of Digits in Java

Objectives :

  • Write a program to compute sum of digits of a given number.
  • Write a program to find sum of digits of a given number.
  • Write a program to calculate sum of digits of a given number.
  • Write a program to compute sum of digits of a given integer number.
  • Write a program to compute sum of digits of a number entered via Command Line.
  • Write a program to compute sum of digits of a given number. Take input from Command Line.
  • Write a program to compute sum of digits of a given number. Take input using Scanner class.

Following is the Java Program to compute Sum of Digits of a given integer number;

Method 1 : Java Program to find Sum of Digits when number is entered from command line

[sourcecode lang=”java”]

class SumOfDigits
{
public static void main(String args[])
{
int n;
int a=0;
int sum=0;

//taking integer number from command line and parsing the same
n=Integer.parseInt(args[0]);

while(n!=0)
{
a=n%10;
n=n/10;
sum=sum+a;
}
System.out.println("Sum of digits: " + sum);
}
}

[/sourcecode]

Steps to run above program via command line :

  1. Compilation : C:\JavaPrograms>javac SumOfDigits.java
  2. Interpretation : C:\JavaPrograms>java SumOfDigits 12345

Output : Sum of digits: 15

Method 2 : Java Program to find Sum of Digits if input is taken using Scanner class

[sourcecode lang=”java”]

import java.util.Scanner;

public class SumOfDigits {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n;
int a=0;
System.out.print("Enter a positive number: ");
n = in.nextInt();

if (n <= 0)
System.out.println("You have entered a negative number.");
else {
int sum = 0;

while (n != 0) {

a=n%10;
n=n/10;
sum=sum+a;
}
System.out.println("Sum of digits: " + sum);
}
}
}

[/sourcecode]

Steps to run above program via command line :

  1. Compilation : C:\JavaPrograms>javac SumOfDigits.java
  2. Interpretation : C:\JavaPrograms>java SumOfDigits 12345

Output :

Trial 1 : With positive number

Enter a positive number: 12345

Sum of digits: 15

Trial 2 : With negative number

Enter a positive number: -12345

You have entered a negative number.

$5 Skill Up Offer

Hello Firends,

With more than 3000 eBooks and video courses available across our website for just $5, you need to know where to start. Download our Year in Review and get the bigger picture on tech in 2015 – and find out what’s set to define 2016.

Banner

How is everyone else Skilling Up for $5?

Our $5 Skill Up campaign has been running for a few days now, and we thought you’d be interested to know what other developers and IT professionals have been learning. Check out this list of our most popular eBooks and Videos so far, all for just $5 each for a limited time!

Buy our one of the Top selling title here and so many other titles for $5 only :

Click here to buy now.

Offer ends on 8th Jan. 2016 so be quick.

How should a trainer handle rude participants in a training workshop?

Objectives:

  • How should a trainer handle rude participants in a training workshop?
  • Do’s and Don’ts for Trainer

The ability to handle rude participants is critical to success as a trainer as each trainer has at one or the other time encountered rude participants. The participants who continue talking, who work on their laptops while you are training, who continuously attend calls on their mobiles, who flat out say you are wrong or you have no clue what it is to be in their shoes, participants who recline on their chairs as if they are in a lounge, who ask irrelevant questions…. the list is endless.

So, what can you do to prevent rude participants from derailing or hijacking a training workshop?

1. Do some pre-work to ensure a great learning environment: Many things impact a participant even before they meet you: how was the training need communicated to them? Do they think they NEED training? etc. Many times these are out of our control but I like to request clients to copy me on emails they send to the participants.

2. Invest some time in the beginning of the session establishing your credibility and getting them to articulate why they should invest their time learning what you are going to cover.

3. Set the training norms collaboratively upfront: your expectations from them, their expectations from you should be on the table and any misalignment needs to be handled. Here come issues like late to class, talking instead of doing assignments etc. Discuss course of action if someone oversteps the boundaries that you all have collaboratively set. Agree on how you will handle disagreements if any i.e. agree on how to disagree.

So, basically we attempt to pre-empt rudeness.

If after all of this, someone is rude, then we can take recourse to some of the following strategies:

1. Isolate what form the rudeness is taking: talking amongst themselves, asking irrelevant questions, negative body language, refusal to engage in any of the activities etc.

2. If the rude participants are in a group, split up the group by doing an activity in which you shift people around in the room. My favourite is to use numbers to divide people into groups as it ensures people who are sitting together are not in the same group.

3. Move the rude participants to the front of the room. Basically near you. Now shower them with your keen attention.

4. Redirect their attention by making them participate in the training activities. Use persuasion.

5. For one off comments, say “interesting point of view, lets discuss in the tea break”, and move on without getting affected.

6. If they are asking questions or expressing views, give the participant a patient hearing and try to see it from their perspective. Let them fully express themselves, then if the question is pertinent to the topic answer it. You can also ask for their permission to park the question and answer it later. If they feel heard they will allow that.

7. Be assertive. Tell them that while you appreciate their views, you have differing views. You could also say that since their concern is not the concern of the majority you will handle it post the session.

8. If time is not permitting then tell them you will discuss it with them in the break. Then do not forget to do so.

9. Do not let it get personal. It should not be your view vs. theirs. Ask other participants for their take on the issue / question. Then wrap up with summarizing the views.

10. Humour if used appropriately, can work wonders.

Simple Interest Example in Java

Starting a series of some Java programs as many students were asking to share the programs. Here is the first program of the series.

Objectives:

  • Write a Program that calculates and prints the simple interest using the formula : Simple Interest = PTR/100
  • How to calculate Simple Interest in Java?
  • Write a program to calculate Simple Interest in Java.
  • Write a Java program that calculates and prints the simple interest using the formula : “SimpleInterest = PTR/100” and input values P, T, R should be accepted as command line.
  • How to use Command Line Arguments in Java?
  • How to pass values from command line in Java?
  • How to take input in Java from console?

 

This particular program can be written in various ways, we will try to write the solution program in different ways here and one can try to understand the difference between them.

Method 1 :

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample {

public static void main(String[] args) {

int p,t,r, result;

Scanner sc = new Scanner(System.in);

System.out.println(&quot;Enter the Value of P : &quot;);
p = sc.nextInt();

System.out.println(&quot;Enter the Value of T : &quot;);
t = sc.nextInt();

System.out.println(&quot;Enter the Value of R : &quot;);
r = sc.nextInt();

result = (p*t*r)/100;
System.out.println(&quot;Interest is : &quot; + result);
}
}
[/sourcecode]

This one is the simplest way to write the program to find simple interest in Java. Here we have simply created the object of Scanner class for taking input. Scanner class was introduced in Java 6. To use Scanner class we will have to import the class from java.util package.

Method 2:

Now we will write a Java program that calculates and prints the simple interest using the Scanner class again but with object oriented programming approach.

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample
{
double principalAmount = 0;
double interestRate = 0;
double term = 0;
double simpleInterest = 0;

public void calculateSimpleInterest()
{
Scanner input = new Scanner(System.in);

System.out.print(&quot;Enter the Principal amount : &quot;);
principalAmount = input.nextDouble();

System.out.print(&quot;Enter the Rate As a decimal : &quot;);
interestRate = input.nextDouble();

System.out.print(&quot;Enter the amount of time in years : &quot;);
term = input.nextDouble();

simpleInterest = (principalAmount * interestRate * term) / 100;
}

public void displaySimpleInterest()
{
System.out.println(&quot;The Simple Interest is : &quot; + simpleInterest);
}
}
[/sourcecode]

Mock Test Program for above code so that we can test the code. keep both the classes in same package and run the Mock Test Program or MockTestProgram.java

[sourcecode lang=”java”]
public class MockTestProgram{

public static void main(String[]args);
{
SimpleInterestExample simpleInt = new SimpleInterestExample();
simpleInt.calculateSimpleInterest();
simpleInt.displaySimpleInterest();
}
}
[/sourcecode]

Method 3:

Now we will write a Java program that calculates and prints the simple interest using the formula : “SimpleInterest = PTR/100” and input values P, T, R should be accepted as command line.

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample {

public static void main(String[] args) {
double p,t,r, result;

p = Double.parseDouble(args[0]);
t = Double.parseDouble(args[1]);
r = Double.parseDouble(args[2]);

Scanner sc = new Scanner(System.in);

System.out.println(&quot;Enter the Value of P : &quot;);
p = sc.nextDouble();

System.out.println(&quot;Enter the Value of T : &quot;);
t = sc.nextDouble();

System.out.println(&quot;Enter the Value of R : &quot;);
r = sc.nextDouble();

result = (p*t*r)/100;
System.out.println(&quot;Interest is : &quot; + result);
}
}
[/sourcecode]

 

I will be sharing more programs soon as many students were asking for programs which were carried out during Java training and were asked in assignments after Java training. By the time enjoy coding in Java and use NetBeans, it will ease your life.

NetCAT 8.1 is ON

Hello everyone,

Jiri Kovalsky, Manager, NetCAT has announced NetCAT 8.1 and I have already registered for the same. And looking forward to have more people from all over the world and specially India for NetCAT 8.1.

NetCAT

You just need to invest few hours per week from mid July 2015 through mid October 2015. And you have to play a little with upcoming version of NetBeans, hunt for bugs and help community to release new and stable version of NetBeans. Make many new friends here and learn a lot from them. Get a chance to work with people having extreme experience and with very high profile in IT. You will never get such a chance with any other company or technology. The main thing you can mention that you have worked with NetBeans for that particular period as a Community Contributor.

Show your love towards NetBeans and technologies that NetBeans supports and earn lots of goodies depending on points you have earned for your work after completion of the program. If you wish you can select specific tribe and you can work with tribe on specific technology.

So what are you waiting for?  Visit http://wiki.netbeans.org/NetCAT and fill registration form, and hit Subscribe button after registration or send a mail to sympa@netbeans.org with subject line as “subscribe netcat” without quotes.

Selected as Member of NetBeans Dream Team

 

Dear all,

I am very happy to inform you that I am selected as Member of NetBeans Dream Team. It is an honor to be a member of NetBeans Dream Team and I am thankful of NetBeans Dream Team and NetBeans Team for considering me and my efforts towards Java and NetBeans, feeling honored since there are around only 50 people selected till now from all over the world and I am the 3rd Indian to be a member of NetBeans Dream Team after Mr, Tushar Joshi (Nagpur, India) and Mr. Rajmahendra Hegde (Chennai and Hyderabad, India).

11th Feb. 2015 was a great day for me, we had festival (Birth Anniversary) of Saint Gajanan Maharaj (Shegaon, Maharashtra, India) and same day only I have received mail with subject as Invitation to join NetBeans Dream Team!. This means all my faith in our saint and dreams have come true.

I am feeling more responsible now and I understand my responsibilities and will work as per guidelines of veteran members of NetBeans Dream Team. I am already working with a new JUG near Pune (Maharashtra, India) that is JUG Nashik (Maharashtra, India)  and will be there for few days with them from 13th Feb 2015. I will be working with 3 JUGs for now that is JUG Nagpur, JUG Pune and JUG Nashik.

For this, I would love to give credit to my family and specially to my Guide cum Mentor, Mr. Tushar Joshi. They have always encouraged me a lot even when many times I could not give them enough time due to hectic schedule of training session all over India. Also I would love to say thanks to my little son for coming in our life as a good luck charm only few days back. My wife was in also worried whether I will be there or not at the time of labor but never complained and said you just do your job, I will take care of everything.

Android Training at Oracle

20141215_175238

 

Conducted 3 days Live and Online Android Training at Oracle Mumbai from Oracle Park, Pune dated 15th Dec. 2014 to 17th Dec. 2014. It was a great experience to conduct training for the giant like Oracle. It is always pleasure and fun working with Oracle people. After the completion of the training received great feedback from all the attendees, glad to see that people out there liked training methodology. I always love to share the knowledge and experiences with the people.