Submitted by secondeye on Fri, 07/30/2010 - 10:02.
::
In today’s world internet marketing and SEO services is at its boom. In the internet world of abundance, internet entrepreneurs attempt to stimulate demand for their products and services. The internet marketplace is flooded with numerous products and product variations, services providers, and 'how to' ideas of thousand of internet experts. This has led to individuals having a wide choice regarding which particular product or service among many he will purchase or subscribe to respectively, to satisfy his wants.
Step 1: Define the Comparator that compares integer values.
import java.util.Comparator;
public class MyIntComparable implements Comparator<Integer>{
@Override
public int compare(Integer o1, Integer o2) {
return (o1>o2 ? -1 : (o1==o2 ? 0 : 1));
}
}
Step 2: Call the Comparator in Collections.Sort.
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Simple2 {
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
list.add(5);
list.add(4);
list.add(3);
You can convert a String to integer using parseInt() method of Integer wrapper class or using valueOf() and intValue() methods together as follows.
str = "25";
int i = Integer.valueOf(str).intValue();
or
int i = Integer.parseInt(str);
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class MainClass {
public static void main(String args[]) throws Exception {
List list = Arrays.asList("a","c","b");
Collections.sort(list);
for (int i = 0, n = list.size(); i < n; i++) {
if (i != 0)
System.out.print(", ");
System.out.print(list.get(i));
}
System.out.println();
}
}
public class ConvertStringToDouble {
public static void main(String[] args) {
String aString = "78";
double aDouble = Double.parseDouble(aString);
System.out.println(aDouble);
}
}
4 answers
I'm trying to sort a HashMap by values. I know that it might not be "good style", but it would save a lot of work, as I wouldn't have to rewrite lots of code if I could just get the HashMap sorted by value.
After lots of searching and trial and error cases I'm still stuck.
The HashMap itself is still unsorted.
import java.util.* ;
public class H
{
static HashMap first = new HashMap();
static
{
first.put("20030120" , new Integer (56));
first.put("20030118" , new Integer (19));
first.put("20030125" , new Integer (25));
Read more »
Created by Anonymous
1 week 6 days ago
Tags:
Submitted by ankit on Mon, 06/14/2010 - 17:51.
::
Ebizon Redfire is an elegant single column theme for Drupal 6. . In this article I will show how we can customize nad make it a three column theme
Its very simple and for that we will need to make changes to our page.tpl.php and style.css.
Changing Page.tpl.php
Look for following text in the page.tpl file
<?php print $content;?>
This is the main content are. We will paste our left block above this region. Use the following code
<?php print $left;?>
Submitted by Anonymous on Tue, 06/08/2010 - 18:32.
::
2 answers
'm have installed java sdk 1.5 on a linux CentOS server. If I run java, I get this error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
How do I solve it?
Read more »
Created by Anonymous
7 weeks 3 days ago
Tags:
Following are the steps on how to install java sdk on CentOS:
Remove any java package (free and open source implementation) previously (eventually) installed from the CentOS Linux as follows:
yum erase jre
Remove tomcat5 and all it’s related packages.
Find the related *).bin file (jdk-6u20-linux-i586-rpm.bin) from the main page of the Sun’s official download page.
After you have downloaded your bin file. Run it on linux shell as follows:
chmod +x jdk-6u20-linux-i586-rpm.bin