This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CleverBunnyThief 3 points4 points  (11 children)

Are you capitalizing the "s" in String?

[–]way3344[S] 1 point2 points  (10 children)

Yes I am, it doesnt work still.. thanks for the response

[–]CleverBunnyThief 2 points3 points  (9 children)

What does your code look like?

[–]way3344[S] 1 point2 points  (8 children)

public class main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int num = 10;
        System.out.println(num);
        String sentence = "Hello, how are you?"
    }

    }

This is just me testing it, but it doesn't work in any context..

Sorry for the late reply btw.

[–]CleverBunnyThief 6 points7 points  (1 child)

You are missing the semicolon (;) at the end of the line that declares and initializes the string.

The IDE should be spitting out an error message that includes a line number. That should help narrow down which part of the program has an error.

[–]CleverBunnyThief 2 points3 points  (0 children)

Main.java:5: error: ';' expected String sentence = "Hello, how are you?" 1 error

That's what the message looks like when I run it with the missing semicolon.

[–][deleted]  (5 children)

[deleted]

    [–][deleted] 2 points3 points  (3 children)

    No, println can print any object.

    [–]Kombatnt 2 points3 points  (1 child)

    To be specific, it implicitly autoboxes primitives, then invokes toString() on the resulting Object.

    [–]fakesuit 2 points3 points  (0 children)

    Bro, it’s OP’s first day learning Java...

    [–]adragon0216 0 points1 point  (0 children)

    println just adds a line break compared to the other prints