Java; Y U NO WORK?

Discussion in 'Off-topic' started by Jeffie0, Jul 31, 2012.

  1. Jeffie0

    Jeffie0 Member VIP

    Hay guys, I started learning Java, the first code (well second, I had a basic knowledge of Java some time ago and created a simple calculator, but that's long gone) I made got 9 errors, it was only 5 lines.

    The Tutorial I'm following is a from 2010 so that's what I'm guessing is the problem but here's my code and the errors I got when compiling, if you have any idea on why this code isn't working please help me.

    Code:

    Errors :c :
     
  2. nrayf

    nrayf Active Member VIP

    I know java, but not at 2 am. Lemme answer you in the morning.
    Pretty much your class name isn't an acceptable one, and you're throwing semicolons where they don't belong. I'll fix it tomorrow
     
  3. Jeffie0

    Jeffie0 Member VIP

    Cool, any help would be appreciated, if I still had the Java Source File for my calculator I could just go off that but I can't find it, all I have are the .class'es
     
  4. nrayf

    nrayf Active Member VIP

    The problem isn't the tutorial, unless it's just a really bad tutorial. Try this site for practice, it shows you the answers if you need help: www.codingbat.com
    All the errors are stemming from your class not being properly defined. (it can't be a number, either). Also, because println is a method, not a variable, it cannot equal something. Instead, you put "hay thar" in parentheses behind println, without an equals sign. Also, out of habit, and because it's easier for bigger programs, I put 'public' in front of my class. That's not necessary.
    This is how I would write the code:

    Code:
    public class HelloWorld
    {
        public static void main(String args[])
        {
            System.out.println("Hello world!");
        }
    }
    
     
  5. Jeffie0

    Jeffie0 Member VIP

    Thanks! Oh and the tutorial was fine, I really don't know why I put an = sign there, it didn't tell me to. And it didn't clarify that a class name couldn't be a number.
     
  6. nrayf

    nrayf Active Member VIP

    As far as I know, class names, variable names, and method names must start with a letter (capital for classes, lowercase for methods/variables), and maybe (?) a dollar sign. But that's some complicated juju. You could have done class C1 and it would have worked.
     
  7. strangecow1

    strangecow1 Member VIP

    It took me 3 weeks to figure out how to put minecraft on my desktop.
     
  8. Jeffie0

    Jeffie0 Member VIP

    Please tell me you're on Linux/Mac, otherwise. Well, never mind, I don't to be rude :p
     
  9. strangecow1

    strangecow1 Member VIP

    Mac, turns out I just had to drag it from the download to the desktop :D
     
  10. Jeffie0

    Jeffie0 Member VIP

    Macs sucks :p
     
  11. strangecow1

    strangecow1 Member VIP

    Macs are much easier to use. It has AMAZINGLY good fps never lags good audio. Your can drag stuff to window to window much easier which is good for mods. How do you beat that?
     
  12. sharqman

    sharqman Well-Known Member VIP

    It's only easy to use if your not planning on doing much tech savvy things on it. you can drag stuff window to window in Windows too.
     
  13. strangecow1

    strangecow1 Member VIP

    Mac is way way better then PC. It is much easier to use. My Mac never crashed, unless i was running a Microsoft program. PC is nice because you have more options to customize it, but most people don't customize their computers anyway. I would rather have a computer that just works and does what i want, without it being complicated. In my experience the mac turns on faster then the PC, i don't have to wait for windows to load. I know for a while Macs really sucked. I think that gave them a really bad name and is why so many PC users are so against them.
     
  14. sharqman

    sharqman Well-Known Member VIP

    cause they suck :p a lot of popular programs/games aren't even compatible with macs. mac's have great hardware (flash ROM/RAM) but it's the OS that matters :p

    I quote my computer teacher
     
  15. strangecow1

    strangecow1 Member VIP

    That's 2 things, what else?
     
  16. Jeffie0

    Jeffie0 Member VIP

    I don't really like the price of Macs either, and I also do a lot more "techy" stuff on my computer, like I have been learning Java, which is possible on Mac, BUT I have also been learning C# (for Xbox App development) which isn't possible.
     
  17. sharqman

    sharqman Well-Known Member VIP

    they are too mainstream. you see them in all of the movies (when they aren't doing techy stuff :p)

    like jeffie just said, macs are a lot more expensive for not that much more

    I choose 1 macbook and 1 ultra book pretty similar

    macbook


    ultrabook

    first off the apple page barely give you info, while the pc page give you just about everything you need to know.

    The only difference i can see without straining my efforts is that the mac has 372 more gb of hard drive space and 1.4 ghz(pc) 3.1 ghz (mac) cpu with a price difference is $300 (you can easily get a 1TB external hard drive for that much). so really the only bonus is the cpu. And if you go to amazon you can get an even better deal.

    amazon laptops

    tl;dr macs are expensive as hell and pcs are better :p
     
  18. Thomasdd13

    Thomasdd13 Active Member VIP

    Fun Fact!
    all apple products are made in a chinese factory called foxconn! the people that work there live about 4 people to a room that is 8 feet by 6 feet. they work standing 14 hours a day, for on average less than or right around a dollar or two a day. the people *chinese laborers* would get so upset at the condition of their lives that they would jump off of the factories roof to kill themselves. apples management issued an order to have NETS hung from the roof so that any one trying to kill themselves would be caught in the net, and sent right back to work. children as old as 7 have also been caught working in foxconn.

    thats the main reason i dont buy anything more than 200$ from them, because cheaper, better and more moral options are available. plus, i love customizing my laptop! in highschool there is so much i have to do with this thing that i want it to feel like its mine. and my cousin has one, when he wants to install stuff or look into his computers hardware, its almost impossible and super hard to do. and you cant take music from your ipod and put it on your mac without opening up its firewalls and such. thats reason 2 :p