473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Java: find elements of one array in another array

I'm trying to write a program that reads words from one array and then finds their definitions in another array.
Here is what I have:
Expand|Select|Wrap|Line Numbers
  1. import java.io.IOException;
  2.  
  3. public class Sampler{    
  4. public static void main(String[] args) throws IOException{
  5.     String[] wordArray ={"Intelligible","Cripple","Bleeper","Accumulate","Envelope","Horse","Gland","Oatmeal","Quarantine","Strait"};
  6.  
  7. ReadDictionaryLines rf = new ReadDictionaryLines(); // class that reads dictionary.txt file          
  8. String filename = "dictionary.txt";           
  9. String[] lines = rf.readLines(filename); // Array holds dictionary lines                      
  10.        }                                     
  11. }
Oct 30 '15 #1
1 1572
chaarmann
785 Expert 512MB
It looks all ok.
But if you want to find something, then an array is definitely the wrong data structure. Just use ArrayList instead. Then you do not need to loop through the array with a for-loop, but can use the contains() und indexOf() methods.

Please show us your implementation of class ReadDictionaryLines that you have done so far.
So where's your problem there , where are you stuck?
Nov 5 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: JKop | last post by:
template<class T> inline T& NthArrayMember( T & (array),size_t i) { return array; } template<class T> inline const T& NthArrayMember( const T & (array),size_t i) { return array;
7
by: Eric Boutin | last post by:
Hi ! I would like to generate an array of type char; I just dont really figure out how I could do it with malloc or calloc.. I mean.. I know how to allocate a simple array with both of them;...
10
by: Steve | last post by:
this code: private Array m_arrays = new Array; results in an array of 3 null Array objects. What am I missing?
4
by: Sandman | last post by:
Hi, So I have 2 arrays: one contains userids. It may look like: user_id =12, user_id =30, user_id =43 The other is a multi-dimensional array with fields like: user_info = Array (
2
by: jimmy | last post by:
Hi, I have an array of type integer which i now want to sort through to find out if all of the elements are equal to one another. I have code that finds the lowest element in the array however i...
19
by: arnuld | last post by:
/* C++ Primer - 4/e * chapter 4- Arrays & Pointers, exercise 4.28 * STATEMENT * write a programme to read the standard input and build a vector of integers from values that are read....
4
by: Bob Bedford | last post by:
Hello, I've an array of array(1,2,3,4). I'd like to retrieve the values in 3 and 4 giving the values 1 and 2. How can I do that, how to search in an array of array ? in short, how to write the...
36
by: laredotornado | last post by:
Hi, I'm using PHP 5. I have an array of strings. What is the simplest way to remove the elements that are empty, i.e. where the expression "empty($elt)" returns true? Thanks, - Dave
2
by: Shellina Reeves | last post by:
Basically I need to create array eleements for an array using rand (). However whenever the code that I provide, the array is filled with the same random array. I am thinking that I need to do...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.