0 Members and 2 Guests are viewing this topic.
MyClass variableName = new MyClass(5);
private int instanceVar;
public class MyClass{ //instance variables! private int aNumber; private boolean amIAwesome; //constructor(s)! public MyClass(/*parameter list goes here*/){ aNumber = 0; amIAwesome = true; //i am awesome by default. } public MyClass(int num, boolean isAwesome){ aNumber = num; amIAwesome = isAwesome; } public void setAwesomeness(Boolean awesomeness){ //public means it can be accessed outside this class. void means it doesn't return anything. amIAwesome = awesomeness; } public int getNumber(){ //int means it returns an integer. note: you can have an empty parameter list. you still need the paranthesis. return aNumber; }}
I recently joined a robotics club at school, and joined the programming team. However, as it turns out, the robot will NOT be programmed with either Axe or TI-Basic (blasphemy!) and will be programmed in Java instead.
What are some common 'gotchas' that might trip me up, especially given that I'm used to coding calculators?
I guess maybe they absolutely want the team to code it in Java. Is it for some sort of java classroom and the teacher decided that it would be in java? That said, in the end, if what is produced is great, I think that's what counts the most, not how it was made. Back in 2004 I remember cases where TI-83+ BASIC games were put down by elitist ASM fanboys just because they were written in BASIC, even if the ASM counterparts weren't even as great (except for speed).
Are there exceptions, though? I remember a year ago the Java applet for IRC on Omni website stopped working completly for many people. After a few java updates, it seemed to work fine, though.
Java can be programmed for mostly anything, as of recently.
if there's one thing java's good at, it's portability its ability for old versions of programs to still work today.
if you try to do something out-of-normalcy in the language, you'll get hit for it because java is all about standards.