Posts

How to get google to index images quickly

Pictures are a valuable way to attract visitors to your site, because visitors search for them using Google, Yahoo and Bing image search. When an image is placed on a page, there is a space for two tags called ALT and TITLE. These tags are displayed to the user when the mouse hovers over a picture. Both an ALT and a TITLE tag are needed.   Before going to indexing, you should confirm about your images that they are visible google crawler So how will you check it Go to: http://www.smart-it-consulting.com/internet/google/googlebot-spoofer/ Some Guideline are here:- Give proper alt, title to the image Define the size(width and height) of image Each image must have unique alt tag Don't use src="images/abc.jpg". Better one is to used src="htttp://www.domain.com/images/abc.jpg" So you have to use full image path to display image in google search.

sum of matrix in java

Image
In this program we are going to calculate the sum of two matrix. To make this program, we need to declare two dimensional array of type integer. Firstly it calculates the length of the both the arrays. Now we need to make a matrix out of it. To make the matrix we will use the for loop. By making use of the for loop the rows and column will get divide. This process will be performed again for creating the second matrix. After getting both the matrix with us, we need to sum both the matrix. The both matrix will be added by using the for loop with array[i][j]+array1[i][j]. The output will be displayed by using the println() method. class summatrix {     public static void main(String[] args)              {             int array[][]= {{4,5,6},{6,8,9}};             int array1[][]= {{5,4,6},{5,6,7}};  ...

file upload using servlet

Hi friends Here is the example to upload a file using java servlet technology. <table> <tbody> <tr> <form action="http://your_host/servlet/UploadServlet?your_config" enctype="multipart/form-data" method="post"> <td> <input name="fname" size="20" type="file" /> </td> <td> <input type="Submit" value="Upload" /> </td> </form> </tr> </tbody></table> import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileuploa...

split string in java

Java equivalent of PHP explode function In PHP we can easily break a long string into smaller parts by using the   explode()   function of PHP. $longstring="I am a cool guy " ; $brokenstring=explode(" ", $longstring); After the execution of the second command the variable $brokenstring is an array such that, $brokenstring[0]="I" $brokenstring[1]="am" $brokenstring[2]="a" $brokenstring[3]="cool" $brokenstring[4]="guy" In java we use String.split() function that achieves the same objective. class splitString     {         public static void main(String[] args)             {             String s1 = " I am a cool guy ";             String[] array = s1.split(" ");                    for(int i=0; i    ...

binary search in java

Image
Binary Search is the fast way to search a sorted array. The idea is to look at the element in the middle. If the key is equal to that, the search is finished. If the key is less than the middle element, do a binary search on the first half. If it's greater, do a binary search of the second half. public class BinarySearch { private long[] a; private int nElems; public BinarySearch(int max) { a = new long[max]; // create array nElems = 0; } public int size() { return nElems; } public int find(long searchKey) { return recFind(searchKey, 0, nElems - 1); } private int recFind(long searchKey, int lowerBound, int upperBound) { int curIn; curIn = (lowerBound + upperBound) / 2; if (a[curIn] == searchKey) return curIn; // found it else if (lowerBound > upperBound) return nElems; // can't find it else // divide range { if (a[curIn] < searchKey) // in upper half return recFind(searchKey, curI...

sort an array of object in java

Image
The java.util.Arrays class has static methods for sorting arrays, both arrays of primitive types and object types. The sort method can be applied to entire arrays, or only a particular range. For object types you can supply a comparator to define how the sort should be performed. All object types that implement Comparable (ie, defines compareTo() method), can be sorted with using a comparator. import java.util.Arrays; public class sortobjects { public static void main(String[] args) { String names[] = { "Ankit", "OM", "Deepti", "Anu" }; Arrays.sort(names); for (int i = 0; i < names.length; i++) { String name = names[i]; System.out.print("name = " + name + "; "); } Person persons[] = new Person[4]; persons[0] = new Person("Ankit"); persons[1] = new Person("OM"); persons[2] = new Person("Deepti"); persons[3] = new Person("Anu"); ...

Quick sort in java

Image
Quick sort algorithm is developed by C. A. R. Hoare. Quick sort is a comparison sort. The working of quick sort algorithm is depending on a divide-and-conquer strategy. A divide and conquer strategy is dividing an array into two sub-arrays. Quick sort is one of the fastest and simplest sorting algorithm. The complexity of quick sort in the average case is Θ(n log(n)) and in the worst case is Θ(n2). Working of quick sort algorithm: Input:12 9 4 99 120 1 3 10 13 Output:1 3 4 10 12 13 99 120 The code of the program : public class QuickSort{ public static void main(String a[]){ int i; int array[] = {12,9,4,99,120,1,3,10,13}; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++) System.out.print( array[i]+" "); System.out.println(); quick_srt(array,0,array.length-1); System.out.print("\nValues after the sort:\n\n...