Tuesday, 17 May 2011

To find minimum and maximum value.

private static int getMaxValue(int[] Value){
double maxValue = Value[0];
for(int i=1;i < Value.length;i++){
if(Value[i] > maxValue){
maxValue = Value[i];
}
}
return maxValue;
}
private static int getMinValue(int[] Value){
double maxValue = Value[0];
for(int i=1;i < Value.length;i++){
if(Value[i] < maxValue){
maxValue = Value[i];
}
}
return maxValue;
}

You can simply copy and paste these methods in your program. You can send array of values as parameter and get minimum or maximum value.

You can also change method return type and type of array to get minimum or maximum of double values

Concat array in JAVA || GWT

By this way array two array can be combine to make one.
This can be used to make size of array variable (virtually).
Objects can be added to the array whose size is defined and array is full.

String[] Value=new String[1];
String[] Value_prev;
String[] Value_temp = new String[10];
Value_prev = Value;

Value = new String[Value_temp.length+Value_prev.length];
System.arraycopy(Value_prev, 0, Value, 0, Value_prev.length-1);
System.arraycopy(Value_temp, 0, Value, Value_prev.length, Value_temp.length-1);

In this code Value is main array where Value_temp array's data is added and Value_prev array is for storing previous data. This can be looped and used to add any many items as desired breaking the limitation of array to be defined at beginning.

This is presently for single dimension which can be extended to multi dimension.

Monday, 9 May 2011

Sorting Array of String in JAVA || GWT

public static void sortString(String[] array)
{
String temp;
for(int j=0; j<=array.length-1;j++){
for(int i=0; i<=array.length-2;++i){
if(array[i].compareTo(array[i+1])>0){
temp = array[i];
array[i] = array[i+1];
array[i+1] = temp;
}
}
}
}

Friday, 6 May 2011

Avoid Virus attacks to your PC

Virus are programs that may run automatically, regenerate automatically and allocate unnecessary memory and makes PC slow and malfunction. Virus are capable of destroying software too by modifying files.

So by understanding Virus. We can avoid them.
1. Do not run unknown executable files or install.(Most important)
2. Install Any one free antivirus.
3. Do not download unknown files.
4. Scan pendrives before using them.
5. keep the file extension shown (folder options). Because viruses can have any fimiliar icon or name but they can have only executable extensions like .exe. So u ll recogzise the virus even if its icon is like folder coz it ll have extension .exe.

Lists of free antivirus are.
-Avira
-AVG
-Avast!
-Bit Defender
-Microsoft Security Essentials (not totally true antivirus but defends unwanted things on PC)