#public static void (add .)

19 messages · Page 1 of 1 (latest)

lyric haven
#

Ay what up, so basically I am a JavaScript expert developer and I am thinking of learning java, anyways, I wanted to make a function for Java using public static void called console.log but I can't add a ., any idea of how to do it?

simple basaltBOT
#

Hey, @lyric haven!
Please remember to /close this post once your question has been answered!

mellow night
#

you cannot have dots in methods

lyric haven
mellow night
#

but you can create an object named console with a method named log

#

but why?

lyric haven
#

yeah that's what im talking about, that's what i want to do

lyric haven
#

it is basic and looks like js that is correct but i really want everything to be simple and easy to understand

ionic ridge
#

I don't mean to discourage you, but this sort of simplification of logging has already been done by SLF4J and its various implementations

mellow night
#
public class YourConsole{
    public void log(String s){
        System.out.println(s);
    }
}

and use it like

YourConsole console=new YourConsole();
console.log("abc");
ionic ridge
#

so that you just do log.info("Hello world");

mellow night
#

Java is not JS and you should accept that

lyric haven
# ionic ridge so that you just do `log.info("Hello world");`

yeah i already know that but i just want it to feel more easier to me as i am a javascript developer, also, i really want to focus on java and it syntaxs but at the same time i dont want to forget much 'bout javascript so i thought it is a good idea to add basic js statements to java as well.

lyric haven