Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can this Java code convert to Javascript code

 
Phoebe Song
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where's your attempt? What problems are you having with it?
 
Phoebe Song
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Where's your attempt? What problems are you having with it?
 
Phoebe Song
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step back for a moment and contemplate: ignoring syntax, what is a 2-D array, really?
 
Phoebe Song
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code I converted to.
 
Phoebe Song
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a syntax error for these lines:


How to replace 2-D array in JavaScript,Use Object?
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic