[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Pure Angst
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 10
Thread images: 3
//private fields of the class
private String species;
private final int name;

//static variable to keep count of objects
private static int monsterCount = 0;

public Person(int = monsterSpecies, int myName){
species = monsterSpecies;
name = myName;
monsterCount++;
}
//This is an instance method
public void setSpecies(String monsterSpecies){
species = monsterSpecies;
System.out.println("This user is now a "+species);
}

//this a void method
//does not return anything
public void printSpecies(){
System.out.println("Species: "+species);
}

/*this is static method, again*/
public static void getMonsterCount(){
String add = "been created.";
System.out.println(monsterCount==1? monsterCount+" person has "+add:monsterCount+" monsters have "+add);
}
public static void main(String[] args) {
//create a new object, obviously a monster for the funsies
Monster me = new Monster("Mike Wazowski", 1);

me.printSpecies();
me.setSpecies("Memes");
me.printSpecies();

Monster.getMonsterCount();
Monster another = new Monster("Donald Trump", 2016);
Monster.getMonsterCount();
}
}

So, anyone else got perfectly good Java Code that the compiler doesn't accept as real?
>>
I know what you did wrong but since youre an SUfag im not gonna tell you.
>>
>>52534731
>REEEEEEEEE
>>
File: 1421137315541.jpg (6 KB, 255x98) Image search: [Google]
1421137315541.jpg
6 KB, 255x98
>>52534731
back to dumblr, you stupid jew nigger retard faggot
>>
>>52534731
It won't compile because you forgot to put

//this is a static method

over main.

But for real what's up with those comments?
>>
>>52535608
Nothing wrong in watching cute lesbian rocks.
>>
Eh, mandatory. It's part of an extra-college-credit thing because I kind of fucked up adding up credits.

Also, it was either that picture or this. And those are literally only pictures I've saved on my computer thus far. (Had it for 5 years. Whoops)
>>
>>52535735
Fuck did I really forget to click the reply to button? No wonder I fucked up this code
>>52535899
>>
>>52534731
ah thanks i need to catch up.
>>
It's not that hard to debug code yourself you know, it looks to me like the signature to your Person constructor is a little fishy
Thread replies: 10
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.