Accessing array
I have array of 5, I've created 5 objects then each of the object has 2 values inside e.g. a card object, it has suit and value(5 of heart), now i want to compare between two card objects whether they are the same cards or not
could you help me to do that?
could you help me to do that?The standard ways is to override the equals method of class Object. In it you define what makes two object equal based on their values.
Similar Messages
-
How to access a Access array in flex
Hi
Guys can any body explain me how to access an array.Actually i am succsufully getting value from array named Dynamic array.
DynamicArray[i].language_1[0].translation;
here the node language_1 is not static it may be language_2 or language_3 or language_4 ect.. so i put that getting value in a variable named key
var key:String = 'language_1'; //Suppose i am getting right value here in key
So please guide me how i access my dynamic array using key so that i got same value as previous code give.
i already tried:-DynamicArray[i].key.translation;
DynamicArray[i][key].translation;
but every time got error.
for more clarity i put array structure here
DynamicArr= Array (@43b1271)
[0] = Object (@43ad219)
contentlanguage_1 = Array (@43b1431)
[0] = Object (@4417a11)
choice_id = "0"
deleted = "N"
downloadurl = "http://94.126.48.105:80/cgi-bin/WebObjects/DataVit.woa/wa/Download/getImage?imageId=1281&f ilename="
selected = "Y"
translation = "2_486"
length = 1
[1] = Object (@4417949)
please Help me out
Thanks In Advance
Vineet OshoHi Vineet Osho,
You haven't tried ---> DynamicArray[i][key][0].translation; This will work
You tried -> DynamicArray[i][key].translation; (This is wrong as you havent specified on which index you want to access)
If still doesn't work ty this...
Try (DynamicArray[i])[key][0].translation;
If the above one doesn't work then try the below one...
var obj:Object = DynamicArray[i];
var translation:String = obj[key][0].translation;
Thanks,
Bhasker -
Accessing array content methods
This is quite simple to do in C++ from what I remember but its got me stumped so far (it is getting late so maybe my brains slowing down).
I simply want to access an object in my array and use its getValue() function to return the value of that object.
Unfortunately I can't seem to do it at the moment.
I presumed i'd be able to do something like MyArray.get(1).getValue.
Basically im looking for the Java version of MyArray[1].getValue()
Sorry to bother you with such a simple question but the search archive had posts focusing on accessing classes from other classes/packages.
Thanksjverd,
I haven't set my array to specifically store a
specific object, however I know it always will.
Are you suggesting there is a better way?Declare the type to be as specific as you can.
If you're only sticking Foo objects in there, declare it as Foo[]. If you're sticking Foo and Bar objects in there, but the have a common superclass or implement a common interface Baz, then declare it as Baz[]. BUT only if you want to use the objects as Bazes. If you're going to have to cast it to Foo or to Bar because you want to access methods that only those classes have--that aren't in Baz--then you probably shouldn't be storing them in the same array.
Storing a single type is also a good idea with Collections. However up through 1.4, you can't declare the type that the collection will hold. With 1.5, generics lets you do that. -
Hey everyone,
I'm new to Labview and am trying to create an array of clusters. I have a 16-channel TTL I/O interface and I want to access each channel of the I/O. Each channel has an input/output boolean button and an output high/low (0 or 5 V) boolean button. I want to be able to read what my output selection is set to with an enum indicator. What's the best way to be able to access, say, channel 7's input/output selection? Or how would I read channel 12's output setting? Thanks a bunch!Hello!
Sounds good -- let us know if we can help out in any way!
Message Edited by Travis M. on 11-01-2005 11:19 AM
Travis M
LabVIEW R&D
National Instruments -
Accessing Array of Structures from Coldfusion
I am having a problem accessing an array of structures from
Coldfusion within my flex application. Here is how I make my Array:
(GetRegions is a type Query and Type is a string variable)
<cfset ReturnArray = ArrayNew(1)>
<cfset ReturnArray[1] = StructNew()>
<cfset ReturnArray[1].Query = GetRegions>
<cfset ReturnArray[2] = Type>
Within flex I am trying to access the results in the
following way:
private function dataHandler(event:ResultEvent):void{
Query_Filter = new ArrayCollection(event.result[0].QUERY as
Array);
myString = event.result[1] as String;
Can anybody help me with this. I want a way to return a query
and a string back from coldfusion.
Thanks for the help,
JeffSo now I changed my code to the following in CF:
<cfset Type = "MyString">
<cfset ReturnArray = ArrayNew(1)>
<cfset ReturnArray[1] = StructNew()>
<!--- set up query GetRegions --->
<cfset ReturnArray[1] = GetRegions>
<cfset ReturnArray[2] = Type>
<!--- Return Array --->
<cfreturn ReturnArray>
Now in flex I have the following dataHandler Function:
Alert.show("hello: "+ObjectUtil.toString(event.result[0]));
Query_Filter = new ArrayCollection(event.result as Array);
Now I set up a List box with Query_Filter as the dataprovider
but the results aren't showing correctly. The first item in the
list box is displayed as [object, Object], [object, Object] and the
second item is my String.
Does anybody know how to break up the query to a variable and
the string to its own variable in the dataHandler function.
Thanks for any and all help -
I cant seem to get the array to be read from outside of the public MyBuffer part of the class. I need to be able to access theArray from the rest of the class. Does anyone know what I did wrong here? Thanks!
public class MyBuffer<T> extends Object implements Bufferer, SaveRestore
public MyBuffer(int x)
Object[] theArray = new Object[x];
public boolean produceItem(Object item)
try {
//puts the items into the array from the assign classes
//THIS IS THE PROBLEM - I need to be able to assign items to the array and in other portions i need to be able to read them back.
//theArray[size]=item;
size++;
return true;
//catches an array exception
} catch (ArrayIndexOutOfBoundsException e){
return false;
}I actually just didnt think of that. Now that works!!!
Now I've gotta get it to write. This method of writing seems to work fine for when I just plug in a number instead of the theArray[i] in there. I dont see why it shouldnt work when all I did was put theArray[i] instead of a number?
This is the error I get:
.\MyBuffer.java:91: cannot find symbol
symbol : method write(java.lang.Object)
location: class java.io.BufferedWriter
out.write(theArray);
And this is my code for that section: try {
BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
for (int i=0;i<=size;i++)
out.write(theArray[i]);
out.write("\n");
out.close();
} catch (IOException e) { -
How do I access array elements in one method from another method?
Hi all!
How do I access the array's elements from another method so that method 2 can have access to method 1's array elements? Thanks for any help!
I am trying to create a simply program that will use a method to create an array and a SEPARATE method that will sort the array's elements (without using java's built in array features). I can create the program by simply having one method and sorting the array within that same method, BUT I want to sort the array from another method.
Here's my code so far:
public class ArraySort {
public static void createArray(int size){
double myArray[] = new double[size]; //create my new array
for(int j=0; j < myArray.length; j++)
myArray[j] = (200.0 * Math.random() + 1.0); //fill the array with random numbers
public static void sortArray(){
// I WANT THIS METHOD TO ACCESS THE ARRAY ELEMENTS IN THE METHOD ABOVE, BUT DON'T KNOW
// HOW???? Please help!
public static void main(String[] args) {
createArray(4); //call to create the array
}Thanks again!
- JohnnyThanks for the help all! I ve managed to get the program working, using java's built in array sort, but when i try to call on the array sort method from WITHIN my main method, nothing happens!
Can somebody please tell me why I am not able to call on the sort method from within my main class???? Thanks!
public class ArraySort {
public void createArray(double[] arrayName, int size){
double myArray[] = new double[size]; //create new array
for(int j=0; j < myArray.length; j++)
myArray[j] = (200.0 * Math.random() + 1.0); //populate array with
} //random Numbers
sortArray(myArray);
} //Sort array(if I delete this & try to use it in Main method --> doesn't work???
public void sortArray(double[] arrayName){
DecimalFormat time = new DecimalFormat("0.00");
Arrays.sort(arrayName); //sort array using Java's built in array method
for(int i = 0; i <arrayName.length; i++)
System.out.println(time.format(arrayName)); //print arary elements
public static void main(String[] args) {
ArraySort newArray = new ArraySort(); //create a new instance
double myArray[] = new double[0]; //create a new double array
newArray.createArray(myArray,4); //build the array of indicated size
//newArray.sortArray(myArray); //This will not work???? WHY?????// -
Accesse array entries within a lower VI hierarchy
Hi
I would like to have access to an array elements within a subVI at lower hierarch. Right now using the property of "callers" I have access to VI refnum at the higher level and "Array elements reference number" enables me to write into the first element of the array but I would like to have access to all elements seperately.
Please consider that I am using LV 8.2 .
Best regards
Afshin
Solved!
Go to Solution.Hi Afshin,
as you already use property nodes you should wire the property "IndexValues" to show the wanted element and then read it's value by "ArrElem.Value". Or search the forum as there are other threads on this topic too
In general: the better (faster, no thread switches, [no] datacopies) way is to wire the array itself to the subvi !
Message Edited by GerdW on 06-07-2009 05:48 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Accessing array elements from the Faces EL
Someone had this question on email and I thought it best to share the answer here.
On Tue, 23 Mar 2004 16:25:23 +0800, zhang xinxin said:ZX> I want to ask you how can output array
ZX> for example
ZX> I define an array in SearchItemBean and bind value to it:
ZX> private String[] array=new String[2];
ZX> public String[] getArray() {
ZX> array[0]="a";
ZX> array[1]="b";
ZX> return array;
ZX> }
ZX> and I can output the array as following:
ZX> <h:output_text id="arra" value="#{SearchItemBean.array[0]}"/> <br>
ZX> but if I wang to output using parameter,it failed:
ZX> in jsp page it write as this:
ZX> <%
ZX> int i=0;
ZX> %>
ZX> <h:output_text id="arra" value="#{SearchItemBean.array[<%=i%>]}"/> <br>
ZX> Can you tell me how to use paremeter in output_text?thanks!
Sure,
The reason what you're doing doesn't work is that anything inside of
"#{}" is for deferred evaluation and is evaluated by the JSF engine,
while scriptlets are evaluated by the JSP engine. I have modified the
guessNumber demo included in the 1.0 release to do what you're trying to
do.
8<-------------------------------------
Index: greeting.jsp
===================================================================
RCS file: /export/cvs/jsf-demo/guessNumber/web/greeting.jsp,v
retrieving revision 1.22
diff -u -r1.22 greeting.jsp
--- greeting.jsp 9 Mar 2004 22:51:27 -0000 1.22
+++ greeting.jsp 23 Mar 2004 16:36:20 -0000
@@ -40,6 +40,7 @@
<HEAD> <title>Hello</title> </HEAD>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+ <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<body bgcolor="white">
<f:view>
<h:form id="helloForm" >
@@ -54,6 +55,10 @@
<h:commandButton id="submit" action="success" value="Submit" />
<p>
<h:message style="color: red; font-family: 'New Century Schoolbook', serif; font-style: oblique; text-decoration: overline" id="errors1" for="userNo"/>
+ <hr />
+ <c:set value="1" var="i" scope="request" />
+
+ <h:outputText id="array" value="#{UserNumberBean.array[requestScope.i]}" />
</h:form>
</f:view>
8<-------------------------------------
What I'm doing here is to store the variable into request scope, then I
can access it using the implicit object requestScope.
This approach should give you what you need.
Ed (EG Member)Thank you for your answer!
but I still have question.
I will output a array,but the size of array is dynamic,
and the size is passed by the SearchItemBean.
How can I control the i to increase to the specify number?
how can I pass the size parameter into the <c:set>?
How can I use a paratemer passed by size and control the "i" to increase to it?
thanks! -
Accessing arrays in other classes
I want to access an array in another class. How do I do it.
Class1
Method1()
Fill OriginalArray[]
Class2
Method2()
If OriginalArray[0] = whatever //how can i access this arrayI want to access an array in another class. How do I
do it.
Class1
Method1()
Fill OriginalArray[]
Class2
Method2()
If OriginalArray[0] = whatever //how can i access
s this array
}It depends. If the array is declared as public you'll be able to access it using the '.' notation:
public class One{
public Object[] a;
public One(){
a = new Object[1];
a[0] = new String("hi");
public class Two{
public void myMethod(){
One one = new One();
System.out.println(one.a[0].toString());
}Otherwise you'll need accessor methods, (get/set). -
Hi,
I have a linked list with arrays of type byte stored in. I have managed to access each individual array using list.get(i) but how can I access an individual element of a specific array in the list?
Thanks and regards,
Krt_Maltavoid f(List<byte[]> list) {
byte me = list.get(0)[17];
} -
Access Array Elements by Arrays Reference
Hi there,
I'm currently working on a vi that writes clusters as recordsets into
specific tables in a database.
Due to this I have a problem filling an array of clusters equal to the
recordset structure of
a table. I wonder if it might be possible to access each element of an
array by using the arrays
reference instead of a local variable. At the moment I couldn't find any
properly working method for
that. Is anybody able to giv me some advice or hint?
Thanks a lot!
Sebastian DauSebastian; Be careful about thinking that you have solved your problem because a technique works--or appears to work. The method you are talking about uses excessive resources, is slow and inefficient and is an open source for race conditions. Right now the thing seems to work, what happens when you have other code executing at the same time, accessing the same data? Or say you install the code on a computer that's faster--or slower--than the one you're using now. Will it still work? If not will you be able to figure out why it suddenly stops working? Or why it only seems to work on certain computers? In terms of performance, you always have to go for the best performance you can because you never know how you will want to use the code in
the future. In other words, you use this VI in one place and you can't notice the performance difference. But what happens when you use this VI in a 100 places in your code? Will the performance loss still be unnoticeable? Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
Efficiency when accessing arrays
I would like to access every element of a small 1D array (10 elements) and perform different operations on each element. Is it more efficient to use an Index Array for every element or to change the array to a cluster and unbundle the cluster. If both of these sound like bad methods to you, what would be the best way of doing this?
ThanksAnother possibility would be to use an autoindexing FOR loop. Place a case structure inside and wire the case terminal to [i]. Create a case for each of the "different" operations and assign each to the desired indices.
Please give a more specific example of what you actually need to do. I am sure there is a simple solution.
If course the question is how different are the operations? If the are "similar" (e.g. multiply vs. divide), you can operate on the array directly. For example if you have an array [1,2,3,4] and want to multiply the first two elements by 100 and divide the last two elements by 2, you could just multiply the array with an array constant of [100, 100, 0.5, 0.5].
Converting an array to a cluster just to get the elements is very silly and will make you eligible for an honorary Rube Goldberg award . Why jump through flaming hoops just to get array elements?? All you need is to resize "index array" to give you 10 terminals. If you want the elements in order starting with element 0 you don't even need to wire any indices.
(see also http://forums.ni.com/ni/board/message?board.id=170&message.id=242977#M242977)
Message Edited by altenbach on 05-27-2007 08:56 AM
LabVIEW Champion . Do more with less code and in less time . -
Accessing Array and Iterating Array list - Need Oracle Pro Assistance
Hi,
This is the third time i am posting the question, :( .
I want some advice on how to iterate through a Array list which has an array of tasks/processes and make calls to the corresponding subprocess for each element in the list.
We are looking for a BPMN approach.
Any example or ideas would be of great help.
My requirement states that i will get a list of tasks from a Rules Engine and i have to use BPM to iterate through the tasks and make calls to each tasks(which is a subprocess call).
In Oracle BPM 11g I would like to use a multi-instance subprocess to send a task to a user for each item in an array. There are an unknown number of rows in the array. Does anyone have a good example of how to do this?
I am using BPM Oracle 11g but any help 10 will also help us.
I am reposting again this question , hoping that someone will help us
Thanks
Edited by: user9083699 on Aug 28, 2010 4:03 AMI am not the expert on 11g, however, in 10g, if I understand correctly... it sounds like you should be able to use PAPI to notify instances/sub processes, etc....
With a list of Instances, you can search for that instance and notify it...
If you have a list of processes, that need to be started, you can create an instance within that process....
user9083699 wrote:
My requirement states that i will get a list of tasks from a Rules Engine and i have to use BPM to iterate through the tasks and make calls to each tasks(which is a subprocess call).If you are just trying to initiate a sub-process, (btw, why would they have to be subprocesses?), It sounds like you should be able to create a global in the process, and just call it with PAPI...
I'm still a little fuzzy, on how this business requirement turned up... however, maybe this helps a little?
-Kevin -
Accessing Array and Iterating Array list
Hi,
I want some advice on how to iterate through a Array list which has an array of tasks/processes and make calls to the corresponding subprocess for each element in the list using BPM 11g
We are looking for a BPMN approach.
Any example or ideas would be of great help.
My requirement states that i will get a list of tasks from a Rules Engine and i have to use BPM to iterate through the tasks and make calls to each tasks(which is a subprocess call).
In Oracle BPM 11g I would like to use a multi-instance subprocess to send a task to a user for each item in an array. There are an unknown number of rows in the array. Does anyone have a good example of how to do this?
I am using BPM Oracle 11g but any help 10 will also help us.
I am reposting again this question , hoping that someone will help us
ThanksOthers probably are getting it, but I'm not really sure what it is that you're tyring to do with the list of instances.
I'm getting lost in two areas. First, you mentioned you have a rules engine returning a list of instances. Mostly out of curiosity - why do you have an array of instances being created by a rules engine? What is the use case? Asking because I'm sure to learn something new from you on this - I'm used to seeing a lot of things coming back from an invoked rule, but never an array of instances before.
Second (sure you know this), in both 10g and 11g there is a Split-N activity that you can use to parse (as the name implies) "N" number of instances. This "N" is discoverable at runtime. If you have 14 instances in your array at runtime, it would go into a Split-N activity and 14 instances would automatically be spawned. The 14 instances would flow from the Split-N to its corresponding Join activity in the process.
Dan
Maybe you are looking for
-
I've had a weird issue under Dreamweaver 8.02. It started under Vista and of course I blamed the OS and went back to XP. Well now it's occurring there as well. It all happens in code view which is where I work all the time. The toolbar buttons will n
-
I am having problems with the Shutting or restart option it wont take either command. What can I do to fix the problem?
-
Audio Won't Merge to Correct Source Tracks
Hi Guys, I'm working on a feature at the moment. The audio is recorded separately on a Cantar. Sound guy usually records up to 8 tracks. Keeping booms and character's radio mics on the same tracks for each scene. When I come to sync the clips in FCP
-
Viewsonic VX2453MH-LED Display Works, but no sound from monitor
I'm using 15" MBP (early 2011), OS X Lion, and I saw earlier threads about this disaply not working (vertical bars). I figured that part out, but am having trouble with no sound coming from the built-in speakers. I have a Moshi HDMI adapter and Vie
-
Need help on sharing a jsp page between clients?
Hi, Let me explain this: In my jsp application I have two jsp pages that work as a find dialog like applet find dialog.One of those shows the columns from rowset(which user can enter the criteria ) and the other gets the values from first one, makes