Why no array literal?
This is really just a philosophical question. The language allows a literal to be used to initilaize an array like this
int[] arr = {1,2,3,4}but later in the code you cannot write
arr = {4,5,6,7};I have always wondered why. Anyone got an insight?
...and the reason is that to create the array, the
compiler needs to know the element type of the array,
but with the elements you use it could be any of byte
short char int float double... so they allow that
expression only when you declare and initialize on
the same line.Hmmm.... I don't buy it. The types are no more ambigous in the second line than the first: int[] arr = {1, 2};
arr = {3, 4}; In both cases, the values could be interpreted as ints, longs, doubles...
But in both cases, it's known that arr is an array of ints, so all that should be required is that the values inside the {} are assignment compatible with int.
Similar Messages
-
Why a array in write method fifo
Hi !
I am a beginner on LabVIEW FPGA, and I have a thing who intrigue me. I use a FIFO Write Method on my vi PC to interact with values of condition on my vi FPGA, the thing which intrigue me it's why the Write Method forces me to use a array on Data and why in the front panel it's the tenth element of the array which can change the value.
This problem many intrigues me, I will be grateful if someone can help me.
Attachments:
PC.vi 200 KB
FPGA_4.vi 68 KBThe host side of the DMA FIFO is always working with arrays. This is because the FPGA can take the data off/put the data in a lot faster than the host can if one item at a time.
You can only change the 11th element because that is the index item you are showing. You can always change the visible index and/or expand the array to show more elements.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Lookup in array literal?
Hello,
Does Java support lookups from array literals? Something like this:
System.out.println(["one", "two", "three"][1]); // outputs "two"Yeah I know it's bad practice, I'm just messing around with some obfuscated code.
Thanks,
Z.I already tried, here are the errors I receive:
test.java:6: illegal start of expression
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: ';' expected
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: illegal start of expression
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: ';' expected
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: illegal start of expression
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: ';' expected
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: illegal start of expression
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: ';' expected
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: not a statement
System.out.println(["one", "two", "tree"][1]);
^
test.java:6: ';' expected
System.out.println(["one", "two", "tree"][1]);
^
10 errorsI also tried {....}[0] as well as String[...][0] and got similar errors. -
WHY IS array CASTING NOT WORKING ?
data object:
class myData extends BaseData
class x
BaseData[] lData = null;
setData(BaseData[] aData)
lData = aData;
getData(BaseData[] aData)
return lData;
class y
myData[] a = new myData[];
x xx = new x();
xx.setData(a);
xx = (myData[])xx.getData(); <---casting doesnt work !!
}well IData IS an array so that's not the problem
The problem is that an array is an object with its own inheritance but it has no knowledge of the inheritance of the objects it contains. So String[] does not extends Object[] even though String extends Object. But all 4 extends Object :)
run this little to see to what interfaces/classes you can cast your arrays:
public class Test {
public static void main(String[] args) {
Class cl = args.getClass();
Class[] interfaces = cl.getInterfaces();
System.out.println( "classes and super-classes" );
while (cl != null) {
System.out.println( " "+cl );
cl = cl.getSuperclass();
System.out.println( "interfaces" );
for (int i = interfaces.length; i-->0; )
System.out.println( " "+interfaces[i] );
} -
Why string arrays not allow in shared variables?
I'm changing a program to replace some global variables with shared variables. The need for an executable is the reason the globals are being replaced with SV's. At least one of the variables is a 2 diminsion array of strings. Under the 'data type' drop down list on the shared variable properties there is no option for an array of strings among the 28 posibilities. Any way this can be accomplished? I'm using version 8.0
thanks, MikeNick, I am attempting your solution. I upgraded to 8.5, created a custom control as a 2 diminsional array and made it a shared variable. it works fine in uncompiled mode but when the programs are made executables the array info is not passed. Now I have to say I find the whole compile process with Labview pretty confusing so I'm guessing I'm doing something wrong in that procedure or I am simply misunderstanding this whole data passing concept on some fundemental level. . I have attempted several different compile property setting under the "Source Files" page. Both the write and read programs are in one project along with the custom control and the shared variable. I compile two applications using the write and read vi's as startup files and have included the custom control and the shared variable in the "always included" area. I've tried including the last two files or not including them in the compile and it makes no difference. Setting the variable as 'single process or 'network published' makes no difference either.
Attachments:
controlrw.lvproj 9 KB -
Why is Array more efficient than flexible-size collection
it is a bit more tricky to understand the two advantges of Array as following:
1. access to items held in an array is often more efficient than access to the items in a comparable flexible-size collection,
2. arrays are able to store objects or primitive -type values, but flexible -size collection can store only object.
thanks in advanceit is a bit more tricky to understand the two
wo advantges of Array as following:
1. access to items held in an array is often more
e efficient than access to the items in a comparable
flexible-size collection,The standard dynamic data structure (with standard I mean member of the collections framework) comparable to the array is the ArrayList. In principle the access to an element is equally efficient in both cases. (There's some overhead because you have to do a method call in the ArrayList case). It's only in very low-level algoritms you need to use arrays. In most cases ArrayList is fine.
2. arrays are able to store objects or primitive
ve -type values, but flexible -size collection can
store only object.This is true with the standard collection, but there are alternative collections that can store primitives, for example,
http://pcj.sourceforge.net/
In the next version of Java there's a new concept call autoboxing. This means there's an implicit conversion taking place between primitive types and their corresponding wrapper class, say between int and Integer. This means you will be able to write your program AS IF you could store primitives in the standard collections. -
Casing Strings to string[] array
Hi,
Beginner question.
Why can i do this:
String[] tmp = {"mike", "Bob", "Jay"};
SomeClass.main(tmp);
But i can't do this:
SomeClass.main({"mike", "Bob", "Jay"});
It does not make sense to me.
It would save me some time if i didn't have to declare a String[] all the time.
Thanks,
-JThe Syntax {"a", "b", "c"} is an array initializer and it can't be used like an array literal. Here are two solutions:
public class Example {
public static void main(String[] args) {
f(new String[]{"a", "b", "c"});
g("a", "b", "c");
static void f(String[] v) {
for(int i=0; i<v.length; ++i) {
System.out.println(v);
static void g(String... v) {
for(int i=0; i<v.length; ++i) {
System.out.println(v[i]);
} [The String... syntax is a vararg|http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html] -
Raid array being seen as 2 individual drives
Hi. Here is the issue as posted in other places. Still searching for the answer to this one.
Specs:
K7n2 delta2 platinum with b50 bios
2x1gb crucial pc3200 2.5cas ram
AMD Barton 2500
2 x 160gb 7200rpm 8mb cache SATA Samsung Hdd's
Thermaltake 430w psu
Gainward fx5700 ultra graphics
OS's: original xp corp, slipstreamed xp corp sp2
raid drivers: nvraid.sys v4.27, 5.10, 5.11 (also the needed nvatabus.sys with those)
I am NOT overclocked.
fsb 166
1:1 ram/cpu
no spread spectrum or other garbage
ddr400 patch disabled
PSU gives presumably stable reading (according to what I see), with amperage ratings above the required.
checked and rechecked cables for bad ones
ran mulitple scans on drives, all come up drives OK
I HAVE installed into Raid 0 already, this is not an issue of hardware failure as far as I am concerned.
So here is the scenario
I have properly set up the array, using correct bios settings and the raid setup utility, for a raid 0 array of those 2 hdd's listed. When booting into xp, either version, I have used all 3 of the driver sets listed. I have been reinstalling to do some performance tests on different configurations.
Anyway, for the last few nights I have been trying to get the windows setup to see the raid 0 array as one 300gb drive. It does not, no matter what I try. It sees them as 2 drives, each being 160gb (or thereabouts). These drives are matched, same firmware, same lot, so that should not be an issue.
I have used numberous tools to delete the mbr on the drives, both in an array and as single drives. I have done the same as well as tried an install and formatted each drive individually, still the same effect when the raid array is recreated.
Basically, I can find no good reason why the array is seen as individuals and not as an array. It is interesting to note, that even though xp setup sees the the array as 2 drives, I can complete the text based portion of setup. However, rebooting to start the GUI portion of setup, it will not boot. Obviously becuase the bios has the controller as the nvraid controller and it is supposed to be a raid 0 array, so I expected that.
Short of rewriting the mbr, either by deleting it or by changing each drive by formatting/partitioning/installing an OS on them, I cannot think of how to fix this. I know the drives and xp cd's work because I have already installed with them.
I understand what to do in the bios portion, and in the raid setup utility portion. I know that I can boot into windows as a single drive and use the nvraid tool to set it up, but that is not the way it should be, and that is not the way I am going to learn WHY this is happening.
Roger that. First set in bios enable raid (in this bios I have to enable IDE array, then choose which controller to actually enable raid on, which happens to have been SATA 1 & 2).
Second, upon reboot, I use the F10 key to enter raid utility. Then, set to striping, set stripe size (which was one of the things I am testing), and add the drives to the array. Next step is to create it. It asks to clear disc data, and it is done.
Have deleted that array as well as just cleared it. Have deleted it and reboot and rebuild it. Have deleted it, reboot, change bios back to non-raid, reboot. Reboot. Change bios back to raid enabled. Reboot. Rebuild array in raid utility, reboot. Run setup, only see 2 hdd's, not one array.
Umm, yep, that is about it.
More to the story now.
From some other posts I tried this.
1. destroy array. reboot. disable raid in bios. reboot. verify sata's visible as singles in bios.
2. power down. pull plugs on sata's. reboot. no drives visible.
3. pull power. jumper clear cmos. wait 60 seconds. re-pin jumper. power up.
4. verify no drives. verify default bios settings. all is good
5. plug drives in. reboot. seen as singles. erase mbr on both drives. reboot
6. enable raid in bios, and choose sata 1 & 2 as "enabled". reboot.
7. use F10 key to setup raid. Here is the interesting part. Even though I deleted the array prior to all of this, and removed the drives to force an ESCD update, and cleard the cmos with the board jumper, and then before raid was enabled, cleared the mbr on the drives, when I started the raid utility, the array was already set up. That is the problem, whatever that is. I have read snippets where it is claimed that this chip or bios or whatever stores some kind of a table on this stuff, but this is a bit out of hand.
That combination, IMO, should have cleared anything out. But, the saga continues.
Thanks for you help BWM
[Edit] BTW, I have finally found a utility that will see a raid array and allow me to clear the arrays mbr. It is called SuperFdisk and is at ptdd.com. So far the only one that see's the 2 drives as 1.
Yeppers.
Started with v5.10 which came on a floppy with the mobo. Told setup to use both, nvatabus.sys and nvraid.sys. Even switched which one of the 2 I picked first, just to see.
Same thing with v4.27 and v5.11. Also tried it with just the nvraid.sys and just the nvatabus.sys (which obviously does squat for raid, lol)
Trying some new things now. Post in a little bit.
I am officially at 'Wit's End'.
Here is what I have tried now.
1.pull drive cables. pull power. jumper clear cmos. wait. power up. no drives
2.plug sata 1 in. boot. drive detected.
3.boot to command.com, run MHDD, which is a nice russian utility similar to Spinrite. Used this to clear the mbr at hardware level, and do a complete erase.
4. reboot to command.com. run superfdisk. erase mbr.
5. pull plug on sata 1, and plug in sata 2 with sata 1 cable. repeat the erasure steps listed above.
6. pull plug on sata 2, no sata plugged in. reboot
7. change bios to raid enable on sata 1 & 2. power down
8. plug in sata 1 & 2. power up.
9. inspect raid utility. no listing of any arrays. reboot
10. in raid utility, build array. did NOT clear discs. reboot
11. attempt install. single drives found again (used both drivers).reboot
12. in raid utility, optioned to CLEAR discs (funny, rebuild option is never valid).reboot
13. attempt install, both drivers, still seen as 2 individuals.
Things to note. When creating an array when presumably there are none, it assigns the raid array an ID of 2. Upon reboot, the ID is now 1. Don't know what difference that makes.
Also, tried the install listed above with APIC functionality both off and on. Also, when on, set MPS to both 1.1 and 1.4. In addition to this, each variant I tried manual HAL layers of, in this order, ACPI (the one that actually spells ACPI out), ACPI Uniprocessor, MPS Uniprocessor, and let it choose it for me.
So, here I sit in a barca-lounger at 'Wit's End', with a warm cup of java and a dinner mint.Here is the final product on the floppy disk that I used to successfully install a stable raid 0 on the MSI K7N2 Delta 2 Ultra 400 Platinum ms-6570e motherboard.
On root of floppy, from driverset 6.70. (after much testing, I used driver pack 5.10 for my nic and smbus. I used the realtek sound drivers off the cd for audio. I have used every driver pack I could find, and while some did offer better I/O or read/write latency, this set in general provided the most stable environment. The only drivers I used were these floppy drivers for SATA, the nic and smbus just mentioned, the sound just mentioned, and updating the nvide drivers to mside drivers)
<from sataraid directory>
disk1
idecoi.dll
nvatabus.sys
nvraid.cat
nvraid.inf
nvraid.sys
nvraidco.dll
<from legacy directory>
nvata.cat
nvatabus.inf
I used the txtsetup.oem from the sataraid directory, but edited this:
[Files.scsi.RAIDCLASS]
driver = d1,nvraid.sys,RAIDCLASS
inf = d1,nvraid.inf
dll = d1,nvraidco.dll
catalog = d1,nvraid.cat
[Files.scsi.BUSDRV]
driver = d1,nvatabus.sys,BUSDRV
inf = d1, nvraid.inf
dll = d1,idecoi.dll
catalog = d1, nvraid.cat
To this:
[Files.scsi.RAIDCLASS]
driver = d1,nvraid.sys,RAIDCLASS
inf = d1,nvraid.inf
dll = d1,nvraidco.dll
catalog = d1,nvata.cat
[Files.scsi.BUSDRV]
driver = d1,nvatabus.sys,BUSDRV
inf = d1, nvatabus.inf
dll = d1,idecoi.dll
catalog = d1, nvata.cat
Now, it is important to note that I installed or attempted to install at least 50 times. Bare minimum. I noticed when I use this custom driver disc that in the GUI portion of setup, XP asks me for files from the disc. I tried lot's of different things to alleviate this, and denied some of them.
One thing that really bugged me was that the bios would see my #2 optical, slave on secondary IDE channel. A dvd/rw drive. And I could even start the setup from it. But, once I got about 3/4 through copy file stage on text setup portion, I would hang. Becuase the drive was no longer accessible. Booting from the master would get me to the desktop, but the slave optical was nowhere to be found. Updating the ATA/IDE controller to the ms ide drivers would get it visible, but I kept having issues with stability after I did that.
The most stable method I found was to use my above listing of driver files for the floppy, and when in GUI mode setup asks about NVCOI.DLL, I skipped it, ignored it, and did not let setup install it. That actually got me to the desktop, with access to the slave optical as a "removable drive". It even knew what the hardware was. It just could not access it. On a reboot however, back to not seeing it. This method however did allow me to update the nvide driver with the mside driver with no stability issues. So, for me it was a raving success.
Here are some links regarding the SATA RAID driver workaround:
http://66.102.7.104/search?q=cache:jHbX5bNfGx4J:www.msfn.org/board/lofiversion/index.php/t51140.html+nforce2+nvraid.sys+ms+ide&hl=en&client=opera
http://www.aoaforums.com/frontpage/index.php?option=content&task=view&id=292&Itemid
http://66.102.7.104/search?q=cache:J9UhG2Kd8W4J:www.short-media.com/forum/showthread.php%3Ft%3D32751+xp+2+sata+raid+0+seen+as+individual&hl=en&client=opera
Early on one problem I noticed was that in text setup mode of xp installation, there were long pauses that I have never seen before. I noticed that with both ide and sata installs. Also I noticed that when booting there was a really long pause when the xp logo is first seen in a sort of dim state till when it became bright and vivid.
Come to find out that this is a more or less typical scenario. Most instances that I read about were all pointing to the nvide driver. So, I found if I just updated the PATA controller to the standard ms ide driver, that went away and the whole system ran better.
It took awhile to figure out that if you install a driver with the nForce2 chip, you had to uninstall it or you will have issues. Herein was the main problem I encountered with the SATA RAID installs. The nvatabus.sys driver was required for an SATA RAID install. Omitting the ata driver was impossible. And for awhile I had no success updating the ms ide driver once I was to the desktop without major instability. Here are some links regarding the drivers for this chipset:
http://www.nforcershq.com/forum/latest-drivers-for-nforce-3-vt60240.html
In my browsing I came across some pretty interesting articles regarding ACPI. One thing I started playing with was the different HAL layers that xp installs on it's own, vs. me picking one manually (F5 key). I must have started the setup at least 50 times to figure out this: that this particular board does not give me the bios settings to install xp with anything but the ACPI Uniprocessor Hal. For instance, the MPS Uniprocessor HAL is much more responsive, but it lacks the IRQ's needed for setup to see the raid array. I booted to each one, some locking the system up, some booting OK. The one I found the best performance with early on was the one that spells out ACPI, not just initialized. (sorry, I don't want to look it up).
I seemed to be getting closer, but I could not find the needed bios settings to properly manage my ACPI, and since I was trying for RAID, I could not use the one that did work. Here is a link for that kind of stuff.
http://www.fceduc.umu.se/~jesruv98/info/acpi/acpi.html
Another thing that I did not like was being forced to use the dynamic overclocking feature of this board. I have a 333mhz barton core, and I have ddr400 ram. In optimized (fool proof) mode in bios, I was running asynchronous. I did not want that. So I set it down to run at 166mhz, with very slow and conservative settings on everything. Unfortunately, if I did this "manual" method, I was forced to use the dynamic overclocking. I thought I had that figured out. So I set everything to "optimized". But, as it turns out, the system had terrible stability without the dynamic overclocking set to at least Private. What this meant is that I could not rule out that my stability issues (corruptions and hangs and bsod) were from being overclocked even a tiny bit or not. And as if that were not enough, this bios has a special set of settings you must unlock to see. And one of those is paramount in achieving a stable system. It is called the DDR400 patch, and it is enabled by default. So, by pressing SHIFT+f2 AND CTRL+F3, these settings are now available. Like I said, I had to disable that DDR400 patch setting.
I also found out from the first day that my board shipped with the latest bios. I flashed the 2 prior versions with no success in more stability. After about 6 weeks of getting whipped on by this board, I found mention of some modded bios's for this board. I have used modded bios's in the past, some worked wonders, others required some serious effort to recover from. What I found out about this board is that there are 2 players who make the modded bios's. Here is the first index I found from a german website. This one actually is for the older B4 version only for the Platinum.
http://storage-raid-forum.de/viewtopic.php?t=2824
And here is an english forum for pretty much the same thing
http://www.nforcershq.com/forum/bios-mods-for-k7n-and-k8-boards-vt55014.html
These links have a bit more information, and I decided to go with these. I tried versions b61,b62 and b71. I found b71 to work the best for me. Mind you I am not into overclocking or what-have-you. Just a rig that performs as well as it was advertised to do. Try these out for the bios information:
http://forums.pcper.com/showthread.php?t=385480
https://forum-en.msi.com/index.php?topic=84715.0B62
Here is a page that had a bunch of misc stuff I found interesting:
http://66.102.7.104/search?q=cache:QkvLeKcbwjQJ:www.amdzone.com/modules.php%3Fop%3Dmodload%26name%3DPNphpBB2%26file%3Dviewtopic%26p%3D75383+nforce2+ultra+nvraid+driver+freeze&hl=en&client=opera
In the end, I have, I think, conquered this board. My findings can be summed up as follows, all in my opion only I guess.
1. There are some ACPI/APIC issues with this board or this chipset. I believe it also included drivers and some can be attributed to XP.
2. There are some major bios issues with this board.
3. There are some major driver issues concerning SATA/RAID. I am not sure who get's the boob prize, nVidia or MSI.
The only way I have found to get RAID 0 installed and stable is to modify my bios (which is a modded beta version), modify my driver disk for SATA/RAID, modify my install sequence for those drivers, modify my drivers within windows after setup, use different drivers from different driver packs for different pieces of hardware, and modify my HAL layer after everything else is done, to achieve peak performance.
If I had not spent soooo much time trying to get a stable install, I would have built up an Unattended CD, which has some possibilities for forcing non WHQL drivers. But, hey man, I am totally burn out on this board. And all it was for is a spare LAN box for when I go to a lanparty. Sheesh. Murphy's law.
Oh, and I also found out, with my own eyes, that the Soyo KT600 Dragon+ that I dumped for this wonderful board, is way faster. Faster read/writes, faster throughput on the nic, faster booting, much faster installs of xp. As a matter of fact, I could get my KT600 to get a consistent thruput on the network to my older KT266a board at 99%. That is pretty fast. 2 of these Platinum boards, on a sweet switch that is tweaked, will only go up to 91%, no matter how much I tweak them. The gigabit connects via a crossover cable at about 38% of full bore. This is tweaked stuff, but still. I listened to the hype. Dual channel memory, giglan, etc etc.
I hope this may help anyone else out there who is still fighting with these issues.
Out.
sul -
How to get the index of framed color box control in 2 D framed color box array
Hi,
In project, I want to show the different status (Std By, TIP, Pass & Fail) with different color for 200 color boxes arranged in 20X10 (2 D array). When user click on any of the array item, I want to show the details, so I want the index of the item. How can I get it?
Thanks,
Shrinivas
Solved!
Go to Solution.Why an array? There's more than one way to skin a cat
See attached
"In theory, theory and practice are the same. In practice, they’re not."
Attachments:
CatSkinned.vi 19 KB -
Formcalc: access = "protected" puts protected literal in field.
Hi. I have a form that has a field, EmpNbr, appearing twice. The two fields share the same name with Data Binding set to Use Global Data. I don't want the second field to be enterable so I set the field to protected using FormCalc, see clip below. When viewing the form in Preview PDF it is indeed protected, the cursor skips the field. However, both fields show the literal protected as the initial field value. Why is the literal protected being populated and how can I prevent it?
If I change the access to readOnly, that becomes the initial value.
It doesn't help if I change FC to JS.
Below is a clip of the access command --
topmostSubform.Page1.EmpNbr[1]::calculate - (FormCalc, client)
$.access = "protected"
Thanks for any insight.
GaryThe calculate event is "special" and is setup to return whatever the script on the event does back to the caller (in your case the field). So if you add a $.rawValue to the end of your script it will return the current value of the field and all shoudl be good. Note that if you used a different event then this woudl not happen as Calculate is the only event that operates this way.
So your script shoudl be:
$.access = "protected"
$.rawValue
Hope that helps
Paul -
Greetings everyone,
Currently I am working on a project for school, this is my first term in Java and a project we have been assigned to do is pretty much create a application (using the SDK for use on the computer only) and create a application where a new user can modify a new computer from a base system via combo boxes, check boxes, radio buttons and what not. Here is me question. I was going to try and get tricky and create a three dimensional array to link the combo box with a label so the end user could choose an up grade, see what the upgrade did and see what the cost was say for instance:
Athlon 64X2 4200+(combo) amd athlon 64 X2 4200+ 2.2GHz 1MB Cache Add $300.00
Each one of those i was thinking i could place in a seperate column and each have a variable already assigned such as array[0][0] = Athlon64X2 4200+ array[0][1]="AMD Athalon 64.." array[0][2]="Add $300.00". I thought that, maybe it is, and i did something wrong and missed something. Anyhow, now i have broke it down to trying to do it with a reg array feeding the combo and the two dimensional array doing teh cost upgrade and the description, i guess my question is, why is it when i seem to try everything to grab the information i set in the array it does not seem to want to pull it. And if and when i do get it to work, how can i link the two dim with the combo. I am rather confused, maybe i am looking more into it then there really is, which i have done in other languages.
If someone could give me a moch code using what i had there so i might clear the fog in me head, it would be greatly appreciated. If i have confused others with my confusion, just ask and i will try to clear it up. Thanks for all and any help.
Whitz3ndThe course i am taking is a rather basic Java programming class. We are using arrays instead of databases to get use to working with handling data. That is why the arrays. If that clears anything up. I know it seems kind of crude, like i said it is a basic Java class.
Here is an easier question, that i would like to know:
in a two dimensional array,
if i had this info:
AMD Athlon64 3100+
AMD Athlon64 3300+
AMD Athlon64 3800+
and
Add $100.00
Add $200.00
Add $200.00
How would i place this data into an array. Would it be this way:
String [][] test = { {"AMD Athlon64 3100+,Add $100.00"}, {"AMD Athlon64 3300+,Add $200.00"},{"AMD Athlon64 3800+,Add $200.00"} };
As i said, i am a new person to the programmaing world, so please excuse my shortcomings! -
SELECT Command on Associative Array
Guys,
I have a question on associative arrays in ORACLE.
I m working on one assignment where I am not allowed to create any object into the database e.g. Create temporary tables, use of cursors etc.
For data manipulation i used associative array, but at the end i want to show that result in pl/SQL developer.
I know that I can't use select command on associative arrays.
Any alternative/solution for it?
Also is there any way that i can write the contents of associative array to a .csv file?user13478417 wrote:
I m working on one assignment where I am not allowed to create any object into the database e.g. Create temporary tables, use of cursors etc.Then cease to use Oracle - immediately. As you are violating your assignment constraints.
ALL SQL and anonymous PL/SQL code blocks you send to Oracle are parsed as cursors. And as you are not allowed to use cursors, it will be impossible to use Oracle as cursors is exactly what Oracle creates... and creates a lot of. For every single SQL statement. And every single anonymous PL./SQL block.
For data manipulation i used associative array, Why? Arrays is a poor choice in Oracle as a data structure most times as it is inferior in almost every single way to using a SQL table structure instead.
Pumping data into an array? That already severely limits scalability as the array requires expensive dedicated server (PGA) memory. It does not use the more scalable shared server (SGA) memory.
Manipulating data in an array? That requires a "+full structure scan+" each time as it does not have the indexing and partitioning features of a SQL table.
Running a SQL select on an array? That is using a cursor. That also means copying the entire array structure, as bind variable, from the PL/SQL engine to the SQL engine. An excellent way to waste memory resources and slow down performance... but hey you can still shout "+Look Ma, no --brains-- hands, I'm not using any SQL tables as dictated by my assignment!+".... +<sigh>+
Any alternative/solution for it?You mean besides using Oracle correctly ?
You could reload the shotgun and shoot yourself in the other foot too. That should distract you for from the pain in the first foot. -
HELP! "array required, but object found" :S
Halo I'm new to Java and on one of my exercises I'm getting the following compile error and don't know why :S
"array required but Deck found"
Here is the code:
//Card.java this defines the Card class and object
public class Card {
private final int rank;
private final int suit;
// Kinds of suits
public final static int DIAMONDS = 1;
public final static int CLUBS = 2;
public final static int HEARTS = 3;
public final static int SPADES = 4;
// Kinds of ranks
public final static int ACE = 1;
public final static int DEUCE = 2;
public final static int THREE = 3;
public final static int FOUR = 4;
public final static int FIVE = 5;
public final static int SIX = 6;
public final static int SEVEN = 7;
public final static int EIGHT = 8;
public final static int NINE = 9;
public final static int TEN = 10;
public final static int JACK = 11;
public final static int QUEEN = 12;
public final static int KING = 13;
public Card(int rank, int suit) {
assert isValidRank(rank);
assert isValidSuit(suit);
this.rank = rank;
this.suit = suit;
public int getSuit() {
return suit;
public int getRank() {
return rank;
public static boolean isValidRank(int rank) {
return ACE <= rank && rank <= KING;
public static boolean isValidSuit(int suit) {
return DIAMONDS <= suit && suit <= SPADES;
public static String rankToString(int rank) {
switch (rank) {
case ACE:
return "Ace";
case DEUCE:
return "Deuce";
case THREE:
return "Three";
case FOUR:
return "Four";
case FIVE:
return "Five";
case SIX:
return "Six";
case SEVEN:
return "Seven";
case EIGHT:
return "Eight";
case NINE:
return "Nine";
case TEN:
return "Ten";
case JACK:
return "Jack";
case QUEEN:
return "Queen";
case KING:
return "King";
default:
return null;
public static String suitToString(int suit) {
switch (suit) {
case DIAMONDS:
return "Diamonds";
case CLUBS:
return "Clubs";
case HEARTS:
return "Hearts";
case SPADES:
return "Spades";
default:
return null;
// Deck.java creates a deck of cards:P
import java.util.*;
public class Deck {
public static int numSuits = 4;
public static int numRanks = 13;
public static int numCards = numSuits * numRanks;
public Card[][] cards;
public Deck() {
cards = new Card[numSuits][numRanks];
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++) {
for (int rank = Card.ACE; rank <= Card.KING; rank++) {
cards[suit-1][rank-1] = new Card(rank, suit);
public Card getCard(int suit, int rank) {
return cards[suit-1][rank-1];
//AND finally, DisplayDeck.java that creates a deck of cards and display the cards of a deck:P
import java.util.*;
public class DisplayDeck {
public static void main(String[] args) {
Deck bobbysDeck = new Deck();
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++) {
for (int rank = Card.ACE; rank <= Card.KING; rank++) {
System.out.format("%s of %s%n",
Card.rankToString(bobbysDeck[suit-1][rank-1].getrank()), //<---here is where I get the error
Card.suitToString(bobbysDeck[suit-1][rank-1].getsuit())); // <----and here too
bobbysDeck is an array, so why is it giving me this compile error? Thank you very much for your help.For the benefit of others, here is Deck displayed with code tags:
public class Deck
public static int numSuits = 4;
public static int numRanks = 13;
public static int numCards = numSuits * numRanks;
public Card[][] cards;
public Deck()
cards = new Card[numSuits][numRanks];
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++)
for (int rank = Card.ACE; rank <= Card.KING; rank++)
cards[suit - 1][rank - 1] = new Card(rank, suit);
public Card getCard(int suit, int rank)
return cards[suit - 1][rank - 1];
}You'll see that Deck holds an array of Card objects in its cards field. You could if you desired directly access that field and use that as an array like so:
public static void main(String[] args)
Deck bobbysDeck = new Deck();
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++)
for (int rank = Card.ACE; rank <= Card.KING; rank++)
Card card = bobbysDeck.cards[suit - 1][rank - 1];
System.out.format("%s of %s%n",
Card.rankToString(card.getRank()),
Card.suitToString(card.getSuit()));
}but this allows outside classes to mess around with the innards of the Deck class in ways that we cannot control and can cause nasty bugs to appear that are very hard to identify and remove. Some class could for instance delete all the Card objects in cards. Much better and much safer is to make Deck's card variable a private variable and to only get the information through public methods, methods that allow the Deck class to control access. Notice that with this method, we can only get the card information; we can't delte or change it. So better is this:
public static void main(String[] args)
Deck bobbysDeck = new Deck();
for (int suit = Card.DIAMONDS; suit <= Card.SPADES; suit++)
for (int rank = Card.ACE; rank <= Card.KING; rank++)
Card card = bobbysDeck.getCard(suit, rank);
System.out.format("%s of %s%n",
Card.rankToString(card.getRank()),
Card.suitToString(card.getSuit()));
} -
Action engine/array question
Im sure there is an easily corrected mistake I'm making. I am going to be making an action engine where I need elements added to an array, and after the array is full, toss away old data and add the new data. If someone can tell me why this array is continuing to be all zeros i'd appreciate it. Probably misuse or misunderstanding of one of the array functions. If someone could put a photo of the corrected VI rather than attach the actual VI it I'd appreciate it as I wont be on a computer with Labview until Monday. Thanks.
CLA, LabVIEW Versions 2010-2013
Solved!
Go to Solution.
Attachments:
actionengine.vi 22 KBIf you could just take a last look at this and make any more comments I'd appreciate it. I'm trying to learn how to do this stuff as efficiently as possible the first time so I don't have to backtrack/relearn. I'll take advice on anything, except tunnel and wiring as I think I can fix that myself. I'm more worried about the actual coding. And yes, I am aware my front panels aren't organized
Message Edited by for(imstuck) on 01-22-2009 02:59 PM
CLA, LabVIEW Versions 2010-2013
Attachments:
actionengine.vi 67 KB
test_action_engine.vi 144 KB -
BD Array Constant cannot be "browsed"?
I've been annoyed by this in the past and a quick search did not yield any answer, so here is it:
Is there a good reason why an array constant on the BD cannot be looked at, in the sense that the array index is no clickable?
For instance, I am parsing a header using an array of strings and while I am debugging the process, I'd like to rapidly check what the index of entry "this" or "that" is so that I can put some conditional probe that will get me there quickly. The problem is, the array is too large to be seen at once on the diagram. Moreover, what I want to do is bring the item I am interested in to the top of the list so that I can check its index:
The problem is, once I step through the code, the array is "frozen" and I can't play with the index control.
That should not change anything to the code, so I don't understand why I am prevented from doing that.
I can browse through cases of a structure or a sequence. Why not an array constant?
Tested in LV 2011, but has been here forever.You are specifically talking about run mode, right (in edit mode you can change the index).
You can show the scroll bar of the array container. It seems that still works in run mode, but I agree that the index should maybe also keep working.
LabVIEW Champion . Do more with less code and in less time .
Maybe you are looking for
-
PO 'No goods receipt possible for purchase order'
Hi gurus! While trying to make Confirmation of a PO in the SRM Portal the user is getting the error 'No goods receipt possible for purchase order' The scenario used is Classic, so PO is replicated directly to the R/3 system. Any idea why this is happ
-
Photoshop Crashing after OSX Software Update!
Help! I'm a graphic designer who uses Photoshop everyday, all day and Photoshop crashes whenever saving files. It started happening right after I updated to 10.4.6. Any help at all would be appreciated... Debbie G4 Mac OS X (10.4.6)
-
I highlighted a pdf with my ipad mini using acrobat and when I got home and opened it again half of what I did is not showing anymore is it lost? How can I recover all this highlighted notes?
-
Touch ID - Biometric reader with problems and no solutions
I have an Iphone 5s Model 1457, after upgraded to iOS version 7.1.2 the biometric reader stopped working. I upgraded to IOS 8.0.2 and continues in the same situation. Already reset all settings and not solved. What should I do? Does the apple can sol
-
OCM for Java EE no longer current?
Is Oracle Certified Master for Java EE still a current certification? I only ask as this is available for JavaEE 5, but not 6. I am concerned this is now a defunkt cert