# Java Source Code: Binary Search in Recursion

4.0″ NEW Cheap Android 4.0 Dual Sim WIFI Capacitive Smart phone AT&T T-Mobile
Current Bid: \$63.95

Below is the java source code for a recursive binary search. The program requires to sort the numbers first in an ascending order before the binary search can be implemented successfully. Basically, what the program does is prompt the user to input the size of the array, enter the numbers that the user wants, sort it, then ask for the number he wants to search. If the number is on the array, it outputs the index of the array where it is located but if it is not on the list is simple returns -1.Here how the program works.

How the program works

Important note: Binary Search algorithm would work only if the numbers are sorted.

For example:

User’s enters: 2 1 3 5 4

The sorted numbers are: 1 2 3 4 5

Search number: 2

The numbers is on the array index 1, since array index starts from 0. if the search number is 6, then the program returns -1, since 6 is not on the list.

## Java Video Tutorials

Java Programming Video Training tutorials CBT 30+ Hrs
Current Bid: \$4.99
Advanced Java Programming Video Training tutorials CBT – 30+ Hrs – Master level
Current Bid: \$4.99
Learn JAVA language -14h video & docs tutorials
Current Bid: \$4.59

## Java Books

Introduction to Java Programming, Comprehensive Version 9e by Y. Daniel Liang
Current Bid: \$50.80
Java Programming Lab Manual by Blayne Mayfield Third Edition
Current Bid: \$14.99

How Binary Search Works?

1. It computes the middle index of the array

From the given numbers above, since there are 5 numbers, we will divide it into 2 to get the middle.

middle = 5/2, returns 2, since they are both integers so any decimal value will not be counted.

meaning on: 1 2 3 4 5, 3 is the middle, Since array index starts from 0.

2. Compare if the search number is equal to the middle if, yes return the index middle.

if(middle == search)

return index middle.

3. If not, it then compare if the search number is greater than or less than the middle. if it is greater than the value of the middle, the search starts at the middle + 1 number till at the last number in the array, however if the search number is less than the middle, it compares next the number located on the middle – 1 index value up to the first value of the array.

The Source code is given below.

Java Source code: How to implement Binary Search Using Recursion.

//Java Class
public class binarySearch //Example of Java Class
{
//biSearch is an example of a method or a function
public int binSearch(int[] arr, int fIndex, int lIndex,int search)
{
int middle = (fIndex + (lIndex – fIndex) / 2);
if(fIndexCool Android Phones!

Android Smart Phone MTK6515 CPU 1.0GHz 4.7 Inch Screen Galaxy S3 9300 Phone WIFI
Current Bid: \$125.00
New LG VX9700 Dare Verizon/Page Plus Touch Screen GPS Cell Phone (No Contract)
Current Bid: \$59.95
Motorola XPRT Sprint Android Smart Phone Rough Shape
Current Bid: \$10.70

## Cool Programmer Shirts

NEW Red Hat Linux Software Programmer T-shirt Size L Large Tee
Current Bid: \$13.99
PROGRAMMER CAFFEINE INTO SOFTWARE NERD GAMER GEEK COFFEE CUP T-SHIRT
Current Bid: \$10.99

Sample Output 1:

Enter the size of the array: 5

Enter 5 numbers: 2 1 3 5 4

The sorted numbers are:

1 2 3 4 5

Enter the number you want to search: 3

The search number is on the index 2

Sample Output 2:

Enter the size of the array: 5

Enter 5 numbers: 3 2 1 4 5

The sorted numbers are:

1 2 3 4 5

Enter the number you want to search: 1

The search number is on the index 0

Sample Output 3:

Enter the size of the array: 5

Enter 5 numbers: 2 1 3 5 4

The sorted numbers are:

1 2 3 4 5

Enter the number you want to search: 6

The search number is on the index -1

## Java Tutorials and Tips

Java Tutorial Examples
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming

## Other Java Source Codes

Java Simple Codes for Beginners
Java Source code: How to Add numbers inside an Array Using Recursion
Java Source code: How to Add Numbers inside an Array using For Loop
A Java source code: How to Output Asterisk in Different Forms Using Recursion
Java Source code: How to Print a String Backward using Recursion
Java Source code on Printing the Greatest Common Divisor (GCD) using Recursion
Java Source Code on a Recursive Linear Search
Here is the Java Source code for the Linear Search implemented in Recursion.
Java source code: How to Output the Answer of the Integer X to the Power Y
Java Source Code: How to make a Program that will determine a Person’s Salutation and Current Age
Java Source Code: How to Sort Numbers in Bubble Sort
Java Source Code: How to Sort Numbers using Selection Sort
Java Source Code: Recursive Snow Flakes

## Do You Love Java?

Yes
No
See results without voting

# How to become a PHP Developer: Learn and Earn

How to become a PHP developer? Indeed, there are many students, programming enthusiasts, web site owners and web designer wannabes, who want to find a good answer and a right guide for this question. I hope this hub would be a stepping stone for them to learn more about PHP.

First what is PHP?

PHP language stands for Hypertext Pre-Processor — it is a server-side scripting language. PHP language is free to use and easy to learn if you have a background in other programming languages — especially if you already learned and applied the basics of Java. PHP is used in order to make webpages more interactive. Hence, in learning PHP, you need to know the basics of HTML, for you to have an easy understanding on making a PHP script. PHP script is what you call to the codes of PHP that are executable on PHP servers. If you want to learn the HTML basics, check out my tutorial here.

## PHP Video Tutorials

“Learn the PHP basics from 17 info packed video tutorials.” “On CD”
Current Bid: \$1.99
PHP Programming Video Training tutorials CBT – 7+ Hrs
Current Bid: \$4.99
Learn php -mysql and web develop video &docs tutorials
Current Bid: \$5.99
Install Scripts 7 Video Tutorials, Learn MySQL Setup , Install PHP, CGI Scripts
Current Bid: \$4.00

Current Bid: \$6.69
Learn PHP and MySQL PDF Ebook And Video Tutorials Course With MRR on CD
Current Bid: \$8.43
PHP Script Store with Products to sell (eBooks & add your own)
Current Bid: \$9.95
1000+ Opportunities, websites, ebooks, videos, php scripts #NP-0003
Current Bid: \$5.73

What are the PHP servers and PHP editors?

There are many PHP servers but the most common are Apache and IIS (Internet Information Services). In order for you to practice offline, you need to install an application, which has an Apache or a PHP server. As for me, I first used XAMPP, it has an Apache and also MYSQL (a database server which is needed to store and manipulate information). If you do not have XAMPP, you may download XAMPP for free here . You can also find tutorial on how to use XAMPP here.

The PHP editors is where you code or make your PHP scripts. Some commonly used PHP editors are Notepad++ and Netbeans editor.

How to learn PHP Programming?

Learning PHP programming is not hard at all, especially if you have an experience in coding html files as well as making java programs. If you have a back ground on other programming languages, you would find that PHP is not that different compare to how other programming languages behave. The syntax of php scripts is easy to understand and easy to follow. What you need to do is to familiarize how the built-in functions work and work yourself through the PHP if-else statements, PHP arrays, Loops and PHP functions. If you understand these PHP basics you could step forwand to advanced PHP, which deals on storing, updating, deleting and retrieving information on and from the database. I guess, that is the most exciting part. At this point, you can already make your own PHP applications as you wish and begin your journey as a PHP developer.

To learn how to program in PHP, check out my tutorials below:

http://aisha91.hubpages.com/hub/Steps-on-How-to-Program-in-PHP-A-Beginners-Guide-on-PHP-Programming

## Cool Android Phones!

Samsung galaxy s ii sprint phone
Current Bid: \$100.99
NEW PANTECH P9070 BURST UNLOCKED 4G ANDROID TOUCH 5MP CAM 16GB PHONE BLACK
Current Bid: \$119.99
Samsung Galaxy Proclaim SCH-S720C – 1GB – Black (Net10) Smartphone Cell Phone
Current Bid: \$61.00

We all know that HTML is a building block on making a website. To have a more interactive website, PHP and HTML should go along together, that is, an HTML file with PHP scripts and a PHP file with HTML tags. You can see example here on how HTML and PHP go along together. HTML is an interpreted language which not needs any compiler in order for it to run. As long as you have a notepad and a browser you can experiment with HTML tags and see the result right away on your browser. If you want to learn more about HTML and to experience on how to code this scripting language, see my other hub here.

## PHP Webpage Design Templates

PHP 6 and MySQL 5 for Dynamic Web Sites Internet /Web Page Design GREAT PRICE
Current Bid: \$19.00
PHP 6 and MySQL 5 for Dynamic Web Sites Internet /Web Page Design GREAT PRICE
Current Bid: \$22.00
New 25,000 Website Templates Graphics Design Sites Busi Scripts HTML PHP
Current Bid: \$.99

How can you run PHP scripts on your website?

PHP is a widely used language use by web masters, so there are many web hosting sites which support PHP. The best example are WordPress, Drupal and Joomla. If you have a web site hosted by a site which supports PHP, then you can make and run your own PHP scripts in your web site template.

So, What do you need on learning PHP first and foremost ?

Actually, you only need,

1. A wondering mind

## PHP and My SQL Video Tutorial

Learn php -mysql and web develop video &docs tutorials
Current Bid: \$5.99
Install Scripts 7 Video Tutorials, Learn MySQL Setup , Install PHP, CGI Scripts
Current Bid: \$4.00
InfiniteSkills PHP MySQL Development Tutorial Video / Training DVD-ROM 16hrs
Current Bid: \$79.96

2. PHP installed server and database server (preferably XAMPP, which has Apache and MY SQL)

3. HTML Basics

Basically, these are what you need on learning PHP. The rest is all depends on your drive to learn. If you have that wondering mind you will not stop asking, reading and finding answers about the in and out of the language. So in the process of finding answers, you are also learning in a most convenient and less stressful way. You can practice first offline and familiarize all the PHP basics by reading my tutorials on here.

Source:Melidacashsource.wordpress.com

Now the final question, how can you earn and make money with PHP?

If you already an expert, you can make money online with PHP language inside the comfort of your own home. There are many paid services online which requires a knowledgeable PHP developer to help them make and fix their web sites. The best examples are Odesk and Elance. If you are really creative, you may also consider on making your own interactive web site, sell your application and offer your own services for a fee. Through this, together with patient, drive to learn and trial and error, you can earn and make money as a PHP developer.

## Protector Glasses for All Computer Users

BLACK OR BROWN WAYFARER COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: \$7.99
Anti-Stress COMPUTER GLASSES Brown WAYFARER Eyeglasses clear sunglasses gunner
Current Bid: \$7.95
BLACK OR BROWN WAYFARER COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: \$7.99
BLACK OR BROWN COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: \$7.99
BLACK OR BROWN COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: \$7.99

## You Might Also Like:

Steps on How to Program in PHP: A Beginner’s Guide on PHP Programming-Part 1
Steps on How to Program in PHP: A Beginners Guide on PHP Programming Part 3
How to run PHP Code or PHP Scripts and See the Result on Your Browser
HTML Basics: Learn The Basics of HTML and Create Your Own Webpage on Your Browser
How to become a PHP Developer: Learn and Earn
PHP Code Example on Foreach Loop and For Loop
PHP Sample Codes On Function:How to make Function in PHP
PHP Code Example on Associative Array and Multidimensional Array
PHP code Example for if statement
PHP Code Example for if-else Statement
PHP Code Example on if else-if Statement
PHP Code Example on Switch Statement
PHP Code Example on While Loop
PHP Code Example on Numeric Array
PHP Code Example on Do-while Loop

# Fibonacci Java Program: Complete Program for Fibonacci Series

Motorola Triumph (Latest Model) – Black (Virgin Mobile) Smartphone Android
Current Bid: \$.99

Java Program for Fibonacci Series

Fibonacci is the sequence of number, which has 2 forms, first is the sequence that begins in 0 and the second form is the sequence that begins in 1. After the constants, the following number is the sum of the first 2 previous numbers. For example:

The constants in Fibonacci Series are:

Fib0 = 0;

Fib1 = 1;

Fib2 = 2;

So, if the next sequence is the sum of the first 2 numbers in the sequence, then, Fib3, Fib4 and Fib5 will be:

Fib3 = Fib1 + Fib2;

Fib4 = Fib2 + Fib3;

Fib5 = Fib3 + Fib4;

And so on…

Thus, Fibonacci Series is easy to predict if you know its rules of sequences. It is also easy to program in Java.

Fib0
Fib1
Fib2
Fib3
Fib4
Fib5
Fib6
Fib7
Fib8
0
1
1
2
3
5
8
13
21

## Example Fibonacci Series of Number 10

Fib0
Fib1
Fib2
Fib3
Fib4
Fib5
Fib6
Fib7
Fib8
Fib9
Fib10
0
1
1
2
3
5
8
13
21
34
55

Fibonacci Java Program Algorithm:

The Java Program for Fibonacci that will be given here is to look for the Fibonacci series of the number that will be entered by the user. Example: 8, the program should return the numbers shown in the Fibonacci series of the number 8 above. The program would test the number 8 and number 10 and let us see if it returns the same as shown on the table.

## Java Source Code for Fibonacci Series

// packageName: fib
package fib;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print(“Enter a number: “);
int entered_num= input.nextInt();
System.out.println(“The Fibonacci Sequence of the Number ” + entered_num + ” is:”);
int constant1 = 1;
int constant2= 1;
int nextNumber = 0;
int count=0;
for (int i=0;i<=entered_num;i++) { System.out.println("F" + count + "=" + nextNumber); constant1 = constant2; constant2 = nextNumber; nextNumber = constant1 + constant2; count++; } } }

## Sample Output:

See all 2 photos
See all 2 photos

It works! Check and trace the code on how the program works. Try it on your Java IDE. Happy Programming!

## Related Java tutorials

5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java Using Netbeans: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming
Java Tutorial Examples
3.2″ Touch Screen 32G Quad Band Java Mobile Cell Phone Bluetooth FM, Pic/Video
Current Bid: \$49.99
Motorola V620 Unlocked Bluetooth Video Camera JAVA Bluetooth Cell Phone Mint
Current Bid: \$24.99

## Java Books

Head First Java, 2nd Edition, Kathy Sierra, Bert Bates, Sierra Kathy, Bates Be
Current Bid: \$19.14
Data Structures and Algorithm Analysis in Java by Mark A. Weiss 3rd ,3e 3ed
Current Bid: \$46.48

## Other Java Source Codes

Java Program: How to Use If Statement in Java Programming
Java Program: How to Use If-Else Statement in Java Programming
Java Program: Using Multi If and Else Statement in Java Programming
Java Program: How to Use Switch Statement in Java
Java Program: How to Parse a String into Integer in Java Programming
Java Program: Count the Number of String Characters in Java
Java Program: Reverse String in Java Using For Loop
Java Program: Palindrome Test Java Source Code
Java Program: How to Sort Numbers in an Array in a Descending Order
Java Program: How to Sort Numbers in Ascending Order
Sample Java Program for String Tokenizer
Sample Program for JOptionpane and Java Source Code for Basic Calculator
What is a Java Scanner Class and How to Use it?
What is MDAS? Sample Java Source Code for MDAS
What is a Static Method in Java?
Casting in Java
Java Source code sample: How to Add Numbers inside an Array using For Loop
Java Source code: How to Add numbers inside an Array Using Recursion

# How to Write Program and Class in Java Using Netbeans: Easy Steps

New K1 TOUCH SCREEN GSM MOBILE PHONE DIGITAL WATCH JAVA MP3 Spy DV CAMERA Black
Current Bid: \$85.00
1st Paperback original. Bill S. Ballinger: Spy in the Java Sea: Signet 295552
Current Bid: \$12.05

This is a step by step process on how to program in Java. First, you must have a Java compiler or Java IDE, the word IDE stands for Integrated Development Environment, Java IDE is use to make simple Java projects. There are many Java IDE’s, as for myself, I use Netbeans IDE for my Java programming projects, and in this tutorial I will also use Netbeans IDE as an example on how to program in Java. Either you have Netbeans or other Java IDE’s it does not really matter, what matters is you must have an idea on how to program in Java in order to make some Java simple projects on whatever Java IDE you have. If you do not have an IDE you can download a free Java IDE or better download Netbeans IDE on the web, just look for it; if you want a safe free download you may browse it at cnet.com, just type cnet: Netbeans IDE on the google search box.

Updated: See how to install and where to download Netbeans IDE for Java Programming here!

How to Program in Java: Complete Simple Easy Steps

Assuming that you now have an installed Netbeans IDE.

Step 1: Open your Netbeans IDE

Step 2: Click FILE located at the left upper side, near the edge, and click the NEW PROJECT.

See all 9 photos
Netbeans IDE Start-up Page

Step 3: Click JAVA at the categories column and click JAVA APPLICATION on the projects column, then click NEXT button below the dialog box. See sample snapshot below.

See all 9 photos
Netbeans IDE snapshot 2

Step 4: Change the name of the PROJECT NAME in the dialog box to whatever names you want that will best describe your ‘will be’ java program, as for this tutorial, I will name the PROJECT NAME ‘javaSampleCoding’. After you finish typing the projects name, click FINISH button below the dialog box. See sample snapshot below.

See all 9 photos
Netbeans IDE Snapshot 3

Step 5: After clicking FINISH, a tab would open which has an embedded name ‘Main.java’. The interface should be like this.

See all 9 photos
Netbeans IDE Snapshot 4

On this Main.java tab, you can now code your first program. You can copy and paste my code on just click this link in a new tab. There are Java simple codes written there especially made for beginners, But before you proceed, read the NOTE below.

Note: Before you copy and paste the code on the link, make sure that you erase all the codes on the Main.java except for the codes in lined with package, as it would duplicate some of the codes if you don’t. The codes on my link above are already complete. You must try first the code that outputs: “This is just an example…” before the second given code. It is just actually like a hello world program. After copying and pasting, your interface should look like this.

See all 9 photos
Netbeans IDE snapshot 5

Step 6: Run it by pressing CTRL + F6 for keyboard shortcut or click RUN -> RUN MAIN PROJECT on the toolbar.

After clicking the RUN, wait a moment. You can see that the program is compiling by looking at the lower left side of the IDE. Then,finally, after a few seconds you can now see the output of the program. It will look like this.

See all 9 photos
Sample Output 1

## Related Hubs

Java Tutorial Examples
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming

If you intend to make a new project, just repeat the steps above. You can experiment on System.out.print(); by changing the text inside it then run again the program to see the word you typed.

To further deepen your experience with Java programming and with Netbeans IDE, you should know how to make a Java class. Almost all of my sample Java source codes are in OOP (Object Oriented Programming), meaning the program is chopped in classes and methods. The codes are divided and is not all placed at the Main.java. The purpose of programming in this way is for the programmers to easily debug the program. Meaning, if there is something wrong with the program the programmers can easily detect it because the codes are chopped in groups.

Furthermore, to make a program that contains Java class, just repeat the STEP 1 – STEP 5, then proceed to STEP 7 below. But before doing this read first the Note below.

## Cool Android Phones!

HTC Droid Incredible Verizon Wireless Wifi 8.0 MP Camera 8GB Android Cell Phone
Current Bid: \$64.95
HTC Evo 4G Sprint Android Smartphone 8MP Cam, GPS, Wi-Fi, Bluetooth (Black) B-
Current Bid: \$43.00
Verizon Wireless HTC Droid Incredible WiFi GPS 8.0 MP Camera 8 GB Cell Phone
Current Bid: \$52.50

Note: As an example for java program which contains class, I will pick the sample java source code for the RECURSIVE DIAMOND SHAPE,This is the link for it. You can name your PROJECT NAME: ‘recursiveDiamondShape’.

Moreover, to identify the codes for java class and the code for main class, find this sign ->//java class, and all the codes below it are java class codes and stop copying if you see this sign-> //main class, because the preceding codes below it is for Main.java.

Now ready? After completing the STEPS 1-5, proceed to next step below.

STEP 7: Bring your cursor to PROJECTS, located at the left upper side just below the tool bar. Click it, then find your PROJECT NAME which is ‘recursiveDiamondShape’ click it, you will see SOURCE PACKAGES folder, then below it is the folder which name ‘recurseiveDiamondShape’, your program’s name. RIGHT CLICK it, then NEW-> then JAVA CLASS -> then name the CLASS NAME this: ‘Diamond’ then click FINISH button below, after that, a new tab will open at your Netbeans IDE which has a name Diamond.java.

For your Diamond.java, copy and paste the //java class codes on the link below. The interface for the Diamond.java, after the copy and paste, should look like this.

See all 9 photos
Diamond.java half body snapshot

For your Main.java, make sure to erase all except for the code in line with package. The interface for the Main.java should look like this.

See all 9 photos
Main.java full body snapshot

Then run the program by CTRL + F6 while you are on the Main.java interface, the sample snapshot for the output looks like this.

See all 9 photos
Program’s output full body snapshot

The program’s output look like the snapshot above if the entered number is 12, to test the program again, just click Run, or CTRL + F6 and enter the number you want then hit ENTER on the keyboard.

## Is this hub clear to you?

Yes
No
See results without voting

## Java Video Tutorial

Java Programming Video Training tutorials CBT 30+ Hrs
Current Bid: \$4.99
Advanced Java Programming Video Training tutorials CBT – 30+ Hrs – Master level
Current Bid: \$4.99
Learn JAVA language -14h video & docs tutorials
Current Bid: \$4.59

## Java Books

Introduction to Java Programming, Comprehensive Version 9e by Y. Daniel Liang
Current Bid: \$50.80
Java Programming Lab Manual by Blayne Mayfield Third Edition
Current Bid: \$14.99
Programming with Java : A Multimedia Approach by Radhika S. Grover (2011,…
Current Bid: \$.99

## Other Java Source Codes Examples

Java Simple Codes for Beginners
Java source code: Print Different Asterisk Shapes in Recursion
Java Source Code: A Recursive Asterisk Diamond Shape
Java Source code: How to Add Numbers inside an Array using For Loop
Java Source code: How to Add numbers inside an Array Using Recursion
Java Source code Print String Backward using Recursion
Java Source Code on a Recursive Linear Search
Java Source Code: Binary Search in Recursion
Java Source Code: Sort Numbers in Bubble Sort
Java Source Code: Sort Numbers using Selection Sort
Java Source code on Printing the Greatest Common Divisor (GCD) using Recursion
Java source code: Recursive function for X to the power Y
Java Source Code Determine Person’s Salutation and Current Age
Java Source Code: Recursive Koch Snow Flakes

# Java Source Code in a Recursive Linear Search

Western Digital WD 500GB My Passport USB 3.0 Portable External Hard Drive
Current Bid: \$46.99

I just finished this java source code on linear search using recursion. Another program to show how array and recursion works. The program will prompt the user to enter all the list of numbers he wants and then he will enter a number to search if it is on the list or not. if it is on the list the program will return the array index of the number and if it is not on the list the program simply return -1.

First Thing First What is a Linear Search?

Linear Search is also known as a sequential search. It search the number the user looking for in an array in a sequential order. First the program must check first if the the index of the array is equal to the last index. Meaning the number in an array is only one, so linear search can’t be performed on an array with only one index. The program must return -1 as said on the paragraph above. However, if it is not, then it checks the index value if it is equal to the number the user looking for, if it is equal it simply output the index number; but if not, it loops again recursively. You can see the source code and sample output below.

Java Source Code on a Recursive Linear Search

//Java source code on linear search using recursion
//Java class
public class Linear_Search
{
public void linSearch2(int[] arr, int fIndex, int lIndex, int searchNum)
{
if(fIndex == lIndex)
{
System.out.print(“-1”);
}
else
{
if(arr[fIndex] == searchNum)
{
System.out.print(fIndex);
}
else
{
linSearch2(arr, fIndex+1, lIndex, searchNum);
}
}
}
//main class
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print(“Enter the size of the array: “);
int size = input.nextInt();
System.out.print(“Enter an array of numbers: “);
int[] arr = new int[size];
for(int i=0; iJava Tutorials and Tips

Complete List of Java Tutorial and Source Codes for Absolute Beginners
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming

If the number is on the list, here is the sample output.

Sample Output:

Enter the size of the array: 6

Enter an array of numbers:35 6 8 65 100 44

Enter the number you want to search:65

The position of the search item is at array index 3

If the number is not on the list, here is the sample output.

Sample Output:

Enter the size of the array: 6

## Java Video Tutorials

Java Programming Video Training tutorials CBT 30+ Hrs
Current Bid: \$4.99
Advanced Java Programming Video Training tutorials CBT – 30+ Hrs – Master level
Current Bid: \$4.99

Enter an array of numbers: 77 4 3 2 56 60

Enter the number you want to search: 7

The position of the search item is at array index -1

Since the array index starts at 0, the length of the array would be size-1, so the returned place of the number in the first sample output would be really 3 and not 4. You can test and try it out on your java compiler. Happy coding.

## Java Books

Introduction to Java Programming, Comprehensive Version 9e by Y. Daniel Liang
Current Bid: \$50.80
Java Programming Lab Manual by Blayne Mayfield Third Edition
Current Bid: \$14.99

## Cool Touch Screens!

Cool Black LED Touch Screen Digital Date Military Men Boys Sports Wrist Watch
Current Bid: \$6.99
Cool Black LED Touch Screen Digital Date Military Men Boys Sports Wrist Watch
Current Bid: \$7.99

## Other Java Source Code Examples

Java Simple Codes for Beginners
A Java source code: How to Output Asterisk in Different Forms Using Recursion
Java Source Code: A Recursive Asterisk Diamond Shape
Java Source code: How to Add Numbers inside an Array using For Loop
Java Source code: How to Add numbers inside an Array Using Recursion
Java Source Code: How to Sort Numbers in Bubble Sort
Java Source Code: How to Sort Numbers using Selection Sort
Java Source Code: Binary Search in Recursion
Java Source code: How to Print a String Backward using Recursion
Java source code: How to Output the Answer of the Integer X to the Power Y
Java Source code on Printing the Greatest Common Divisor (GCD) using Recursion
Java Source Code Determine Person’s Salutation and Current Age
Java Source Code: Recursive Snow Flakes

# Count the Number of Vowels in Java String

Count Number of Vowels Java Program

Counting the number of vowels in a string is another Java Program for beginners. At first this program can just read a word because of the limitation in using the next() predefined method, but if you want to read and check the entire string together with the spaces and commas entered, use the predefined method nextline() instead.

This program use the nextLine() predefined method for better demonstration. You can also change it into next() method if you want to see the difference.

Program Algorithm:

The program that is provided in this hub will prompt the user to enter a string according to his wishes and the program would count the number of vowels regardless of how many spaces entered in the string. The vowels will be check using the charAt() predefined method and will loop it until it reach the maximum number of characters that the string has. Whether the vowels are in upper or lower cases the program will still count it, leaving no vowels behind that are uncounted.

See the output of this program. Try it also on your Java IDE. Happy Programming!

## Java Source Code: Count Number of Vowels in a String

import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print(“Enter a String: “);
word = input.nextLine();
int count =0;
for(int i = 0; i < word.length(); i++) { if(word.charAt(i) == 'a' || word.charAt(i) == 'A') { count++; } else if(word.charAt(i) == 'e' || word.charAt(i) == 'E') { count++; } else if(word.charAt(i) == 'i' || word.charAt(i) == 'I') { count++; } else if(word.charAt(i) == 'o' || word.charAt(i) == 'O') { count++; } else if(word.charAt(i) == 'u' || word.charAt(i) == 'U') { count++; } } System.out.println("Number of vowels: " + count); } }

## Sample Output:

Is this program useful to you? Rate it below. Any question about the program, you are welcome to ask at the comment section.

## Related java Tutorials

5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java Using Netbeans: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming
Java Tutorial Examples

## Java Online Traning

JAVA PROGRAMMING CBTs Video Training Tutorials 9+ Hours
Current Bid: \$9.95
Java 1.1 Certification Training Guide by Cary Jardin (1998, Hardcover)
Current Bid: \$3.99

## Java Video

3.2″ Touch Screen 32G Quad Band Java Mobile Cell Phone Bluetooth FM, Pic/Video
Current Bid: \$49.99
Motorola V620 Unlocked Bluetooth Video Camera JAVA Bluetooth Cell Phone Mint
Current Bid: \$24.99

## Java Book

Java Fern Narrow Great Beginner Plant easy to care for!!!
Current Bid: \$2.39

## Other Java Source Codes

Java Program: How to Use If Statement in Java Programming
Java Program: Using Multi If and Else Statement in Java Programming
Java Program: How to Use If-Else Statement in Java Programming
Java Program: How to Use Switch Statement in Java
Java Program: How to Parse a String into Integer in Java Programming
Java Program: Count the Number of String Characters in Java
Java Program: Reverse String in Java Using For Loop
Java Program: Palindrome Test Java Source Code
Java Program: How to Sort Numbers in an Array in a Descending Order
Java Program: How to Sort Numbers in Ascending Order
Sample Java Program for String Tokenizer
Sample Program for JOptionpane and Java Source Code for Basic Calculator
What is a Java Scanner Class and How to Use it?
What is MDAS? Sample Java Source Code for MDAS
What is a Static Method in Java?
Casting in Java
Fibonacci Java Program: Complete Program for Fibonacci Series
Java Source code: How to Add numbers inside an Array Using Recursion

# PHP Code Sample in Coding if else-if Statement

PHP code, PHP code example on if, else-if statement. A conditional statement on PHP Programming. Given sample code output.

This hub contains php code example of if else-if statement. Like the php code examples on php conditional statements, this php file is also connected with a html file.

Note: The name of html file is form3.html and the php file is elseifstatement.php. If you wish to try this code better save it with this file name too. If you do not know how to run an html file on your browser please take a look on this hub that offers steps on how to do it. And also, if you do not know how to run a php file, read this hub too to know how it is done.

So, now, let start!

## form3.html Sample Code

Enter Year of Birth:
Enter Month of Birth:
Enter Date of Birth:

See all 3 photos

## PHP Code Example on elseifstatement.php

\$date)
{
\$age = (date(“Y”) – \$year) – 1;
echo “Your current Age is: “.\$age.” yrs. Old.”;
}
else
{
\$age = (date(“Y”) – \$year);
echo “Your current Age is: “.\$age.” yrs. Old.”;
}
}
?>

See all 3 photos
See all 3 photos

## PHP Video Tutorials

“Learn the PHP basics from 17 info packed video tutorials.” “On CD”
Current Bid: \$1.99
PHP Programming Video Training tutorials CBT – 7+ Hrs
Current Bid: \$4.99
Learn php -mysql and web develop video &docs tutorials
Current Bid: \$5.99
Install Scripts 7 Video Tutorials, Learn MySQL Setup , Install PHP, CGI Scripts
Current Bid: \$4.00

A Beginners Guide on Running this Code

To provide more clarification for beginners, just follow the steps below to be able to test the codes above.

2. Open the XAAMP and run the apache and mysql

3. Copy and Paste the code on form3.html on notepad++ and save it to where you install your XAAMP and open the Xaamp folder on that drive, open htdocs folder and save the file there with the same file name I have given.

4. Save the elseifstatement.php like you did above.

5. Go to your browser and type this on the address bar: localhost/form3.html

## Protector Glasses for All Computer Users

BLACK OR BROWN WAYFARER COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: \$7.99
Anti-Stress COMPUTER GLASSES Brown WAYFARER Eyeglasses clear sunglasses gunner
Current Bid: \$7.95
BLACK OR BROWN WAYFARER COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: \$7.99

## Other Sample PHP Codes and Tutorials

How to become a PHP Developer: Learn and Earn
Steps on How to Program in PHP: A Beginner’s Guide on PHP Programming-Part 1
How to run PHP Code or PHP Scripts and See the Result on Your Browser
PHP Sample Codes On Function:How to make Function in PHP
HTML Basics: Learn The Basics of HTML and Create Your Own Webpage on Your Browser
PHP Code Example on Associative Array and Multidimensional Array
PHP Code Example on Foreach Loop and For Loop
PHP Code Example on Do-while Loop
PHP Code Example on Numeric Array
PHP Code Example on While Loop
PHP Code Example on Switch Statement
PHP Code Example on if else-if Statement
PHP Code Example for if-else Statement
PHP code Example for if statement

# Java Source code: Reverse String in Java Using Recursion

HTC Inspire 4G -4GB- Black (Unlocked) Smartphone 8MP Cam, WiFi, Bluetooth Great
Current Bid: \$108.85

Recursive Program on Reverse Letters/String

Reverse string in Java programming or printing a string backward using recursion is just a short program, which prompt the user to enter a string and the program output the last character up to the first character of the entered word. Originally, I used array on this but learned that it was not a wise decision so, I used the java predefined function charAt() instead. You can use charAt() if you want to extract a single character of the string. if you did not encounter charAt() yet, see the code below on how it works. Using charAt() is such a useful way to have a reverse string in java.

Java Source code: Reverse String in Java Programming

//Java source code on how to print a string backward using recursion
//java class
public class StringBackward
{
public static void reverseString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-1));
reverseString(word, size-1);
}
}
}
//main class
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print(“Enter a word: “);
word = input.next();
StringBackward access = new StringBackward();
System.out.print(“The reverse word is: “);
access.reverseString(word, word.length());
System.out.println();
}
}

## Java Tutorials and Tips

Java Tutorial Examples
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming

Below is the sample output of the program.

Sample Output:

Enter a word: hubpages

The reverse word is: segapbuh

Sample Output 2:

Enter a word: hubbers

The reverse word is: srebbuh

This is just how the program works, you can also make this program as a reference for a palindrome test using boolean. If the program is palindrome or the reverse word is the same as the original word return true and if not return false.

## Java Video Tutorials

The Java Tutorial : A Short Course on the Basics by Alison Huml, Kathy…
Current Bid: \$1.99
Complete InfiniteSkills Java Programming Tutorial / Training DVD Bundle – 18hrs
Current Bid: \$119.96

## Java How To’s

FAST SHIP – DEITEL 9e Java : How to Program B75
Current Bid: \$28.76
Java How to Program Lab Manual (5th Edition)
Current Bid: \$4.32

## Other Java Source Codes

Java Simple Codes for Beginners
Java source codes on outputting Asterisk in Different Forms Using Recursion
Java Source Code: A Recursive Asterisk Diamond Shape
Java Source codes on Adding numbers inside the Array Using Recursion
Java Source code on Adding Numbers inside the Array using For Loop
Java Source Code: How to Sort Numbers in Bubble Sort Using Recursion
Java Source Code: Sort Numbers using Selection Sort
Java Source Code on Linear Search Using Recursion
Java Source Code: Binary Search in Recursion
Java Source code on Printing the Greatest Common Divisor (GCD) using Recursion
Java source code: How to Output the Answer of the Integer X to the Power Y
Java Source Code: How to make a Program that will determine a Person’s Salutation and Current Age
Java Source Code: Recursive Snow Flakes

# Basic Knowledge Required in Programming

UGOOD’s High Quality Cheap Android Smartphone Fashion Women’s Mobile Phone X8 BL
Current Bid: \$31.00
4.0″ NEW Cheap Android 4.0 Dual Sim WIFI Capacitive Smart phone AT&T T-Mobile
Current Bid: \$63.95

There are basic knowledge required in programming and it must be learned so that someone would be able to work for his/her simple programming projects. Below is the simple list of the basic knowledge required in programming. This hub is only intended for those who want to know how to program and just a quick guide on what should be learned if someone is a beginner in programming.

1. Know How to Declare Variables

Variable can be any name that will choose by the programmer, however the best practice mentioned is that the variables must be related to what the program does to avoid confusion for the programmer while coding. Variables are associated with data types like int, double, long, float, short, string, boolean, char etc.

Example:

int num1, int num2;

double num1, double num2;

String word1, String word2;

char ans;

2. Know How to Use Basic Flow of Controls

If and else statement, while loop, do while loop, for loop and switch statement are but an example of basic flow of controls. For c++ and java language the use of these controls have only a very little difference though the syntax or logic on using these controls are the same. Knowing the basic flow of controls is very important in programming because it almost carries all the implementations wanted by the programmer in his program.

source:bostinno.com

## Java Tutorials and Tips

Java Tutorial Examples
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming

3. Acquaint yourself with Arrays and Function

If you have a programming book you must know how to use arrays and functions, these two are widely used in simple programming as well as in higher programming. Learning it and be an expert on using it will give you many advantages in the future as a programmer.

Somehow, these are all I can think of that will help a beginner in his/her first step as a programmer. Simple programming projects consist only of all these three. The use of arrays and implementing a function call depends on what programming language someone use. But for whatever programming language you want to learn, knowing these three would be a big help. If you want to know more about the programming language you use, delving deeply on its pre-defined functions would help you a lot to have an excellent program. I would upload sample codes using java language and some of them are in OOP. They are simple programming projects that you can test and run on your compiler.

Just a question, what programming language you are most interested to learn and use? We might share the same favorite language. ^_^

## Java Video Tutorials

Java Programming Video Training tutorials CBT 30+ Hrs
Current Bid: \$4.99
Advanced Java Programming Video Training tutorials CBT – 30+ Hrs – Master level
Current Bid: \$4.99

Updated:

Below are simple programming projects that were coded in netbeans java compiler, you might want to have a glance on it or try it on your own java compiler. Those are all working codes.Choose the source code you want below.

## Java Books

Head First Java, 2nd Edition, Kathy Sierra, Bert Bates, Sierra Kathy, Bates Be
Current Bid: \$19.14
Data Structures and Algorithm Analysis in Java by Mark A. Weiss 3rd ,3e 3ed
Current Bid: \$46.48
Excellent Condition Iphone 4 8gb LIKE NEW! Cheap Price!!
Current Bid: \$46.00
Apple iPhone 4 8GB (Verizon) GOOD Condition! ~ with Accessories! ~ CHEAP!
Current Bid: \$157.98
APPLE iphone 3 GS USED/UNLOCKED/WORKS/FACE CRACKED/CHEAP!!!!
Current Bid: \$41.00
Apple iPhone 4 8GB (Verizon) GOOD Condition in BOX! ~ CHEAP ~
Current Bid: \$184.97

## Other Java Source Code Examples

Java Simple Codes for Beginners
Java source codes on outputting Asterisk in Different Forms Using Recursion
Java Source Code: A Recursive Asterisk Diamond Shape
Java Source code on Adding Numbers inside the Array using For Loop
Java Source codes on Adding numbers inside the Array Using Recursion
Java Source Code: Sort Numbers using Selection Sort
Java Source Code: How to Sort Numbers in Bubble Sort Using Recursion
Java Source Code on Linear Search Using Recursion
Java Source Code: Binary Search in Recursion
Java Source code: How to Print a String Backward using Recursion
Java source code: Output the Answer of the Integer X to the Power Y
Java Source code on Printing the Greatest Common Divisor (GCD) using Recursion
Java Source Code: How to make a Program that will determine a Person’s Salutation and Current Age
Java Source Code: Recursive Snow Flakes

# Java Program: Reverse String in Java Using For Loop

Pink Tablet 7 inch cute girl style pretty Q8 Android 4.0.4 ICS cheap eReader PC
Current Bid: \$57.44

How to make a reverse string in Java using for loop?

We have a reverse string tutorial using recursion in our collection of Java Tutorials here, however I made another reverse string java program using for loop for my another Java Tutorial, the Palindrome Test. Like the reverse string in recursion, this reverse string in for loop is also a very small program. But I prefer this one than the other. It is easier to understand and to trace than the one in recursion. I bet you would also prefer this. See the code below for the verdict.

## Other Java String Programs

Sample Java Source Code Program for String Tokenizer
Java Program: How to Parse a String into Integer in Java Programming
Count the Number of Vowels in Java String
Java Source code: Reverse String in Java Using Recursion

## Java Source Code on Reverse String using For Loop

package reverse_string_in_java;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print(“Enter a String: “);
String string = input.nextLine();
System.out.println(“Reverse String Result: “);
for(int i=1; i<=string.length() ;i++) { System.out.print(string.charAt(string.length()-i)); } System.out.println(); } }

## Related Java Tutorials:

Complete List of Java Tutorial and Source Codes for Absolute Beginners
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
How to Program in Java Using Netbeans: Complete Simple Easy Steps
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming

## Cheapest Tablet PC’s

8GB 7″ Google Android 4.0 Tablet PC A13 Capacitive Screen Camera MID Wifi White
Current Bid: \$65.95
7″ Capacitive White Tablet PC Android 4.0 A13 1.2GHz 4GB WiFi Bundle Keyboard
Current Bid: \$69.95
10.1″ Google Android 4.03 Tablet PC 8GB 1GB DDR3 HDMI Bundle 10″ Keyboard
Current Bid: \$119.99

## Other Java Source Code Samples:

Java Program: Palindrome Test Java Source Code
Java Program: Using Multi If and Else Statement in Java Programming
Java Program: How to Use If Statement in Java Programming
Java Program: How to Use Switch Statement in Java