HashMap in java ?
private HashMap map = new HashMap<String,Integer>();
public void put(String name, int value){ map.put("Ru lu ",90); }
public Set getNames() {
return map.keySet();
}
}
public static void main(String[] args)
{
NumberNames n = new NumberNames();
}
}
output :
D:\>javac NumberNames.java
NumberNames.java:4: illegal start of expression
private HashMap map = new HashMap<String,Integer>();
^
NumberNames.java:5: illegal start of expression
public void put(String name, int value){ map.put("Ru lu ",90); }
^
NumberNames.java:9: ';' expected
}
^
3 errors
[702 byte] By [
Tatona] at [2007-10-3 3:04:36]

> You need to provide more code (using [code] tags)
> because I don't think the code you provided is the
> source of your problem.
>
> P.S. There are other more minor problems but get this
> major problem fixed first.
public NumberNames() {
private HashMap map = new HashMap<String,Integer>();
public void put(String name, int value){ map.put(chuchu, 9); }
public Set getNames() {
return map.keySet();
}
}
public static void main(String[] args)
{
NumberNames n = new NumberNames();
}
}
Tatona at 2007-7-14 20:54:38 >

import java.util.*;
public class NumberNames
{
private HashMap<String,Integer> map = new HashMap<String,Integer>();
public NumberNames()
{
}
public void put(String name, int value)
{
map.put(name, value);
}
public Set getNames()
{
return map.keySet();
}
public static void main(String[] args)
{
NumberNames n = new NumberNames();
}
}
Message was edited by:
sabre150
import java.util.*;
public class NumberNames
{
private HashMap<String,Integer> map = new HashMap<String,Integer>();
/*public NumberNames()
{
}*/
public void put(String name, int value)
{
map.put(name, value);
}
public Set getNames()
{
return map.keySet();
}
public static void main(String[] args)
{
NumberNames n = new NumberNames();
}
}
Tatona at 2007-7-14 20:54:38 >
