CryoEnix Posted January 6, 2005 Posted January 6, 2005 Hi there guys, I wasn't sure which area to post in, so I thought this one best. I'm currently writing an encryption program side by side in Java and VB.NET, to compare performance differences and generally get the hang of Java (I'm new to it). Problem is, I have this code to initialize the encryption class in VB: Dim NewEnc(1024) As ClassEnc6 For Num = 1 To UBound(NewEnc) NewEnc(Num) = New ClassEnc6("encryptionkey") Next How do I recreate this in Java? I've tried all sorts, and any Java documentation I can find is way over my head. Any ideas? Quote Chaos is merely logic beyond human comprehension
ThePentiumGuy Posted January 6, 2005 Posted January 6, 2005 (edited) ClassEnc6 NewEnc() = new ClassEnc6(1024); for(int num = 1; num < 1024; num++) { NewEnc(num) = new ClassEnc6("encryptionkey"); } I don't know the ubound command in java. It could be NewEnc.GetLength Edit: there might be a semicolon after num++. I have to brush up my Java/C++ skills. Haven't used them in so long (VB.NET is addicting :D) Edit2: Also I'm assuming you know how to create the basic program (just to get it running.. ex; Creating the public static void main(String args[]) function...etc). if you need help on that I"ll post some code. Also, i'd recommend JCreator Pro, it's a 30 day trial, however Xinox software seems to release new versions all the time, and if you give them your email they'll send you updates and let you "try" their new software for an extra 30 days. What they don't realize is, this is a cheap way to keep the software forever (legally). -The Pentium Guy Edited January 6, 2005 by ThePentiumGuy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Himo Posted January 6, 2005 Posted January 6, 2005 There's no ; behind the last argument in a for loop. And you're sure that this class also exists in Java(not sure if this is a custom or VB .net class) Some mistakes though: ClassEnc6[] NewEnc = new ClassEnc6[1024]; for(int num = 0; num < NewEnc.Length; num++) //Arrays begin at index 0 { NewEnc[num] = new ClassEnc6("encryptionkey"); } And I would recommend JBuilder Personal from borland as it is free. :) Quote For questions about VS .net extensibility, please fire at me! :) For readability, please use the [ CS][/CS ] tags
ThePentiumGuy Posted January 6, 2005 Posted January 6, 2005 There's no ; behind the last argument in a for loop. And you're sure that this class also exists in Java(not sure if this is a custom or VB .net class) Ah. Thanks for clarifying. Yeah it should be a custom class, I haven't heard of a ClassEnc6 in vb.net or java. I'm pretty sure it doesn't matter where the square brackets go. Edit: Heh, corrected myself. Square brackets. I forgot about that. Yeah I was going to mention the index. CyroEnix, it would be better if you started your array with index 0 and ended with 1023 (unless you wanted 1025 elements in your array by ending with 1025), remember, 0 is an element. -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Himo Posted January 6, 2005 Posted January 6, 2005 But declaring Array[1024] gives an array of 1024 elements. 0 to 1023. Quote For questions about VS .net extensibility, please fire at me! :) For readability, please use the [ CS][/CS ] tags
ThePentiumGuy Posted January 6, 2005 Posted January 6, 2005 That's what I said ;). Yeah I was going to mention the index. CyroEnix, it would be better if you started your array with index 0 and ended with 1023 (unless you wanted 1025 elements in your array by ending with 1025), remember, 0 is an element. Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
CryoEnix Posted January 9, 2005 Author Posted January 9, 2005 (edited) ThePentiumGuy, Himo... What can I say? You guys are the dog's! I mean, have you ever been so grateful for some help that you'd be willing to go to someones door to thank them personally? That's where I am now - of course, there's the transport issue, and I don't think you'd be too chuffed with a new stalker. Enough of the ranting, thanks a million - gonna start playing with that code right away! On the note of arrays, since .NET's removal of manual dimming (3 to 6, for example), I've been dimensioning them one higher than usual - in this case, from 0 to 1024 and ignoring the 0. I find this especially useful to find out if there's anything in an array - as trying a Ubound() on an undimensioned array tends to make VBN scream like a girl. Edited January 9, 2005 by CryoEnix Quote Chaos is merely logic beyond human comprehension
ThePentiumGuy Posted January 10, 2005 Posted January 10, 2005 How bout using collections? They start at 1 and they're easy to work with. Dim c as new collection c.add(myclass) But you can't control where that item goes unfortunately, it goes "on top". So c.Item(1) would be myclass. .NET's removal of manual dimming (3 to 6, for example), Those were the good old days.... :D. -TPG Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Himo Posted January 10, 2005 Posted January 10, 2005 What about Vectors? They're in Java.Util.Vector (I think, has been a while) and functions like dynamic uber-arrays. They have a InsertAt/RemoveAt function and a can contain everything, thanks to explicit casting, I love it. Just an extension. Quote For questions about VS .net extensibility, please fire at me! :) For readability, please use the [ CS][/CS ] tags
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.