This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Can this Java code convert to Javascript code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Can this Java code convert to Javascript code" Watch "Can this Java code convert to Javascript code" New topic
Author

Can this Java code convert to Javascript code

Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
Hi everyone,

I have a Java method that I'd like convert it to JavaScript function, is this conversion doable? Here is the Java code.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Where's your attempt? What problems are you having with it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
I need to use this function either at Server side or at Client side. If I can convert this code to JavaScript function, then I can use it at the client side, which is much much simpler. If I can't, I've to summit a request to call this function at Server side. I'd prefer use it at client side.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Bear Bibeault wrote:Where's your attempt? What problems are you having with it?
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
The problem is 2 dimensional array in Java, however in JavaScript, when I try to define 2 dimensional Array, I have a syntax problem. Say how to define this two lines in JavaScript.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Step back for a moment and contemplate: ignoring syntax, what is a 2-D array, really?
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
Here is the code I converted to.
Phoebe Song
Ranch Hand

Joined: Jan 17, 2002
Posts: 54
I have a syntax error for these lines:


How to replace 2-D array in JavaScript,Use Object?
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Yes, you just need to use the correct syntax. to get there, it would help you if you first did Mr. Bibeault's exercise.

Step back for a moment and contemplate: ignoring syntax, what is a 2-D array, really?


and (http://www.hunlock.com/blogs/Mastering_Javascript_Arrays) has a complete explanation of javascript array creation and use.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Can this Java code convert to Javascript code
 
Similar Threads
u_int8_t in java
LinearProgramming in Java
Please help in this selection sort
Returning only minimum value...
RMI server client