Results 1 to 8 of 8
Like Tree3Likes
  • 3 Post By sunde887

Thread: Can't work out why this won't compile...

  1. #1
    Domos123 is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Question Can't work out why this won't compile...

    https://ideone.com/iA4Vg
    It's supposed to convert an inputted decimal number to binary but simply won't compile... Any idea why?
    Sorry if it's obvious,I only just started learning java

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Please paste the code in code tags, most people won't follow links.
    [code]
    YOUR CODE HERE
    [/code]
    Fubarable, DarrylBurke and Dark like this.

  3. #3
    Domos123 is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    Java Code:
    Public Class DecToBin
    {
    public static void main (String[] args) throws java.io.IOException
    {
    int first=(int)args[0]
    int[24] bin
    int i=0
    int count=23
    divide:
    bin[i]=(int) first/(2^count)
    first=first%(2^count)
    i++=
    count--=
    If count>-1 Then
    Goto divide
    Endif
    System.out.println(bin[])
    }}

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    That won't compile because it's simply not valid Java code and has too many errors to enumerate. You'll need to study Java syntax before you try to create it because the compiler is very unforgiving of errors. You can start here: Learning the Java Language

  5. #5
    Domos123 is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    I realise it has errors, I was just wondering what they are... Like I said,I only just started with java
    Last edited by Domos123; 06-21-2011 at 11:32 PM.

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Like fubar said, there is too much wrong to explain, follow his link.

    For starters, statements end with a semi colon(;), you also can't cast a string to int. You also use many non existent words.

  7. #7
    bigsonny is offline Senior Member
    Join Date
    Nov 2010
    Posts
    164
    Rep Power
    4

    Default

    Just out of curiosity Domos, are you coming from another language or is this your first programming language? I'm just wondering what you know so far?

    Either way, they're right. Your code just screams out I do not know the Java Syntax yet, so that's where you should start. Good luck!

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by Domos123 View Post
    I realise it has errors, I was just wondering what they are... Like I said,I only just started with java
    They are that you don't know Java syntax. Don't try to salvage this code, but rather scrap it and fix the problem: learn Java syntax.

Similar Threads

  1. would this compile?
    By stringkilla in forum New To Java
    Replies: 10
    Last Post: 10-24-2010, 03:27 PM
  2. Can't Compile
    By sidk47 in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 06-15-2010, 04:43 PM
  3. Replies: 6
    Last Post: 02-06-2009, 08:05 PM
  4. auto-compile won't work on svn import
    By anacapa in forum Eclipse
    Replies: 0
    Last Post: 10-10-2008, 04:46 PM
  5. Not able to compile
    By bugger in forum New To Java
    Replies: 2
    Last Post: 01-09-2008, 10:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •