Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Why can't it compile ?

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why can't the following code be compiled ? Any help is appreciated, thanks =)

 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

WeiJie Lim wrote:Why can't the following code be compiled ?


What makes you think it won't compile ? If you get compiler errors you need to tell us what they are.
 
WeiJie Lim
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stuart A. Burkett wrote:

WeiJie Lim wrote:Why can't the following code be compiled ?


What makes you think it won't compile ? If you get compiler errors you need to tell us what they are.



I tried compiling it, it wouldn't be compiled.

The errors are repeated.

dum1.java:4: error: illegal character: \160
    static Scanner sc = new Scanne
^
dum1.java:4: error: illegal character: \160
    static Scanner sc = new Scanne
^
dum1.java:4: error: illegal character: \160
    static Scanner sc = new Scanne
^
dum1.java:5: error: illegal character: \160
    public static void main(String
^
dum1.java:5: error: illegal character: \160
    public static void main(String
^
dum1.java:5: error: illegal character: \160
    public static void main(String
^
dum1.java:5: error: illegal character: \160
    public static void main(String
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:7: error: illegal character: \160
        // declarations
^
dum1.java:7: error: not a statement
        // declarations
^
dum1.java:8: error: illegal character: \160
        int numberOfMarbles;
^
dum1.java:8: error: not a statement
        int numberOfMarbles;
^
dum1.java:8: error: illegal character: \160


.... ... .. ( repeated similar errors )

100 errors
 
Bartender
Posts: 825
5
Python Ruby Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you did copy-paste from another site and get bunch of errors in your IDE (like I did with your code, because syntax looks fine) there probably are some special characters invisible in your IDE that you "picked" from the source (white spaces, usually).

edit: Yep, \160, lots of these special characters in your code.
 
WeiJie Lim
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kemal Sokolovic wrote:If you did copy-paste from another site and get bunch of errors in your IDE (like I did with your code, because syntax looks fine) there probably are some special characters invisible in your IDE that you "picked" from the source (white spaces, usually).

edit: Yep, \160, lots of these special characters in your code.



Dang, I thought I replaced all the wrong quotation marks.. Guess there are still some special characters which I can't spot.

I wanted to test out the code from a book.. oh well.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can either retype the code yourself, or wherever you have blanks (white space, new line, etc.) remove it and reformat your code again. The first is certainly better, since it's not a lot of code, you can do it quickly.
 
WeiJie Lim
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay found those offending weird characters in UTF-8 .. Thought it was ANSI .

Thanks for the help =)
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic