Hi guys, I'm almost finished my assignment. It's purpose is to translate english words to pirate language. For example, when some enters "hello", "ahoy" is returned. But when I enter two words like "pardon me", "null" is returned even though I have assigned "avast" to it. I'm thinking this is because I have included Console.readToken() instead of readString(). But token in my opinion works better. So I'm not sure what I can do for more than one word like "pardon me" or "excuse me". Can anyone help? Here is the code: [CODE]import java.util.*; public class PirateTranslator { public static void …

Member Avatar
Member Avatar
+0 forum 3

Hi, I have a java class that is being used by multiple people (from a UI). In the class i have a static HashMap with the userKey as the map key and an arraylist with data pertaining to the user as the value. I am using this kind of like a cache. Because populating the list everytime the user logs in is a very expensive procedure. Whenever a user logs in and modifies the data i am updating the list for that user in the map. Now the issue is that I donot want to keep the entries in the …

Member Avatar
Member Avatar
+0 forum 4

I have the numbers 0-8 so I can represent a state as 012345678 012345687 .... 876543201 876543210 This gives me 40320 ways to represent a state so I have a HashMap of size 40320 and I need a good way to make sure each state only corresponds to 1 key 1-40320 I'm not really sure how to even come close to making sure there are no possible collisions. Any help would be greatly appreciated

Member Avatar
Member Avatar
+0 forum 2

Working with polymorphism collections, list, arraylists etc. I have a sorted collection that I would like to split based on one of the objects properties. All records > 0 to one; all less than to another. I'm trying to think of the best way to implement this. I'm thinking Comparable/Comparator sorting and then iterating through the collection until I hit 0 and splitting there but it also occurs to me that theres gotta be an easier way.

Member Avatar
Member Avatar
+0 forum 5

dear all, I am working on hashmap and treemap. At the starting of my program i have declared two map,m1 and temp,both are hashmap. At starting point both map contains same kay value pair. At some instance of program, i want to change the value in temp, remove some key value pair and after some processing i want to again get original value of remaining key from m1. So my problem is when i am copying value frm m1, instead of value address of that value is cpoied,so later my m1 map doesn't contain original value. here i am showing …

Member Avatar
Member Avatar
+0 forum 3

Dear all, I have declared following two hashmap. `public static HashMap<Integer,String[]> m1 = new HashMap<Integer,String[]>();` `public static HashMap<Integer,String[]> temp = new HashMap<Integer,String[]>();` At starting point of my execution both map will contain key from 1 to 20 and mapped value with it. Means key value pair are same in both map. After some processing i modify value in temp map and do operation on it. for(int r = 0;r<q;r++) { Set s = temp.keySet(); Iterator it1 = s.iterator(); StringBuilder sb = null; String[] a1 = null; while(it1.hasNext()) { a1 = temp.get((Integer)it1.next()); System.out.println("\n /////////////////////////////////////////////////////////////////////////"); if(len[r]>2) { sb = new StringBuilder(a1[loc[r]]); rep …

Member Avatar
Member Avatar
+0 forum 4

Dear all, I have stuck with one problem. I have taken one Hashmap, Performing some input operation,remove operation on it. So after performing remove operation, i want value of 2 successive key in two different array. Also i want to match 1st key's value with all other keys' value. Like 1st key value matched with 2nd kay value,then 3rd key value upto last key Again 2nd key value matched with 3rd kay value,then 4th key value upto last key. I ahve also make some code but it's not working properly. Here "m1" is my hash map.Originally there were 20 key …

Member Avatar
Member Avatar
-1 forum 5

I have a hashmap with key as unique word in string and value as count of duplicates word in string. I want to arrange the output by value. ex: String is "my name is my name and is my my". Output as: my 4 name 2 is 2 and 1 Plz help me achieving this.

Member Avatar
Member Avatar
+0 forum 1

0 down vote favorite I am currently making an application to store employee details such as name, id and email address. I am doing this using a HashMap. I am currently having difficulty with a searchByName,id and email address methods. How would i go about writing one ? Here is my code: //Imports. import java.util.Scanner; //******************************************************************** public class MainApp { private static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { new MainApp().start(); } public void start() { EmployeeStore Store = new EmployeeStore(); Store.add(new Employee ("James O' Carroll", 18,"hotmail.com")); Store.add(new Employee ("Andy Carroll", 1171,"yahoo.com")); Store.add(new Employee ("Luis Suarez", …

Member Avatar
Member Avatar
+0 forum 3

Hey i am making an application that stores employee's details and the output is different than what it should be i was expecting the output to be the toString() in the employee class can anyone see anythin wrong: //Imports: //******************************************************************** //Employee Class. public class Employee { //Variables. private String employeeName; private int employeeId; private String employeeEmail; //******************************************************************** //Constructor. public Employee(String employeeName, int employeeId, String employeeEmail) { this.employeeName = employeeName; this.employeeId = employeeId; this.employeeEmail = employeeEmail; } //******************************************************************** //Getters. public String getEmployeeEmail() { return employeeEmail; } public void setEmployeeEmail(String employeeEmail) { this.employeeEmail = employeeEmail; } public String getEmployeeName() { return employeeName; …

Member Avatar
Member Avatar
+0 forum 2

I'm trying to write a method that displays the contents of a hashmap on screen. This hashmap contains Strings and an array of int for every String. I've put the String aspects of the hashmap into an arraylist and I'm trying to use another method to print the arrays for each String. I've tried the two methods above as well as some variations on the two and in all attempts when I try to print the marks, I get something like "I@1d501268" rather then an actual String. I assume this means that the array hasn't been correctly translated into a …

Member Avatar
Member Avatar
+0 forum 1

Hey guys. I'm new to this site. I just wanted someone to look over the code I have so far for a hash table that operates on linear probing. I don't have anyone to really check these things for me as my professor is always busy. Can anyone tell me if there are any bugs, errors, typos, etc? This code compiles, but has I think 2 warnings. Please give me some feedback if you have the chance. It would be much appreciated. #include <iostream> using namespace std; const int tablesize=1001; int lcounter=0;//# of linear probes int qcounter=0;//# of quadratic probes …

Member Avatar
Member Avatar
+0 forum 1

Hi, I am trying to pass the value of imgPath into imageAdapter.java. I manage to get the result from the toast. But i did not know how to write a proper code to display the value at myRemoteImages. Please help me out. PictureActivity.java [CODE]ArrayList<hashmap<string, string="">> imgList = new ArrayList<hashmap<string, string="">>(); try { imageLink = json.getJSONArray(TAG_IMG); for(int i = 0; i < imageLink.length(); i++){ JSONObject c = imageLink.getJSONObject(i); String imgPath = c.getString(TAG_PATH); HashMap<string, string=""> map = new HashMap<string, string="">(); map.put(TAG_PATH, imgPath); imgList.add(map); Toast.makeText(this, map.get(TAG_PATH), Toast.LENGTH_LONG).show(); } }catch (JSONException e) { e.printStackTrace(); } ((GridView) findViewById(R.id.grid_layout)) .setAdapter(new ImageAdapter(this,imgList));[/CODE] ImageAdapter.java [CODE]public class ImageAdapter extends …

Member Avatar
Member Avatar
+0 forum 1

Earlier on, in [URL="http://www.daniweb.com/software-development/java/threads/412571"]this thread[/URL] my question was answered about how to add objects of a custom class I called State into a HashSet which was a value for a key in a HashMap. [CODE]Map<String, HashSet<State>> mapping = new HashMap<String, HashSet<State>>();[/CODE] However, I need to ensure that there are only [I]distinct[/I] State objects in this HashSet. The way that I know they are distinct is by a char that is stored within a State. However, the HashSet does not know that. Can we please discuss a clear explanation of: [LIST=1] [*]The default behavior of a HashSet to ensure that the …

Member Avatar
Member Avatar
+0 forum 5

hi, [CODE] public Record get(VideoObj v) { // TODO if((v ==null) || (v=="")) return null; else return ??; } [/CODE] Recor and VideoObj are classes. if the methos return type is Record, can someone tell me what should I return? thanks

Member Avatar
Member Avatar
+0 forum 9

I am new to C++ coding. I want to know how hash_map and list can work together. My requirement is: I have a structure with address elements, name My hash key should be name of address object. Using the key I should find out structure. I have dynamic list for address object. I am got struck up getting hash values from hash_map iterator. Can anyone help me in this regard? I wrote some code, but it is not complete [CODE] #include<stdio.h> #include<string.h> #include<hash_map> #include<list> #include <iostream> using namespace std; using namespace __gnu_cxx; typedef struct { char strAddrObjName[20]; char strStartIP[16]; char …

Member Avatar
Member Avatar
+0 forum 1

i have to impliment a chained hash table. in this prog i am using java.util.LinkedList. in one node of linklise i have to store two object-- 1)key value 2)value but java.util.LinkedList. provide add(object) method. that means i can not add two elements in one node of linked list. then how to implement it ?? please suggest. thanks

Member Avatar
Member Avatar
+0 forum 3

Hi, I am fairly new to Java and am about to begin a programming course in the next week. I am preparing by completing exercises and am stuck on this particular one. Basically, i need to read a file in a certain format and calculate some figures and writing the result to another text file. In dot points: -read a text file with teh following format (jobtype, jobname, no_dependent_jobs, depend_job_name, depend_job_name2, etc.) for example: A,Plan,0 B,Build,1,Plan C,Test,2,Plan,Build C,Maintain,2,Plan,Build etc. -I need to calculate stats such as how many jobs are waiting for 'Build' to finish before it can start, number …

Member Avatar
Member Avatar
+0 forum 1

Hello, this is a newbie question, sorry for that, I am trying to port some Java code to C++. In this code I have a hashmap connecting string values to float arrays of varying sizes. They are specified like this: [CODE=Java] HashMap <String, float[]> hm = new HashMap <String, float[]> (); hm.put("C", new float[] { 3, 0, 0 , 1, 0, 1 , 0, 1, 1 , 0, 5, 1 , 1, 6, 1 , 3, 6, 1 } ); hm.put("D", new float[] { 0, 0, 0 , 2, 0, 1 , 3, 1, 1 , 3, 5, 1 , …

Member Avatar
Member Avatar
+0 forum 4

Hi! I have an array of doubles that I map to a hashmap to keep track of the indices of the elements. I want to be able to sort the array and still keep track of the indices and thats no problem as long as the elements are distinct. But when I encounter 2 or more elements in the array that are equal my whole scheme fails since they will get the same index. I see two solutions to the problem: 1: Find a way to generate better keys for the elements (dont know how to do this) or 2. …

Member Avatar
Member Avatar
+0 forum 3

ok so i have 3 separate classes: Product, Action, and Invoice. Action would be my interface that allows me to add and remove items in my hashmap that is in my Invoice class. my Product class would have the instance variables name, info, id and quantity (correct me if I'm wrong, I should have these as private variables). Also in my Product class are my getters and setters getID etc. Now I am kind of confused on how to add items into my hashmap with ID being the key and name info and quantity being the values. [CODE] public class …

Member Avatar
Member Avatar
+0 forum 3

[CODE] my %distAvail; foreach (map(split(/\D+/,$_),<STDIN>)) { $distAvail{$_ }++; };[/CODE] What does [COLOR="#ff0000"]$distAvail{$_ }++;[/COLOR] mean here? The input is set of distances separated by whitespace (or any non-digit character). The book says %distAvail keys are distances and whose values give the number of copies of the key. But I don't understand how [COLOR="#ff0000"]$distAvail{$_ }++;[/COLOR]works.More over I have read that systax of map is [COLOR="#ff0000"]map EXPR, LIST;[/COLOR] but <STDIN> is not a list(i.e array) but a string of distances. Please correct me.

Member Avatar
Member Avatar
+0 forum 5

Hi guys, First, many thanks for reading my post, happy to have found you! I have data(objects) that is stored in a hashmap, my goal is to store this data in a JTable, using a separate cell for each entry, rather than starting on a new column each time. I am creating my own table model (as I want it to detect the correct data type, and customize the data in certain ways). My Hashmap is being initialised and fed in my table model's class. My question is: is there a way I can somehow create a new JTable by …

Member Avatar
Member Avatar
+0 forum 6

The End.