This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi All. Sometimes, when I try to add a simple method to exisitng codes, JAVA would give me this error : non-static method compressedSize(int) cannot be referenced from a static context : int cmpSize = compressedSize(cmpSize); Can someone explain to me what this means please ? TIA
The concept of static is usually confusing for newbies, I know I was initially confused when I started to learn Java. The simple answer is: That error will occur if a block of code in a static method attempts to access a non-static variable (e.g. instance member) or call a non-static method. A brief explanation: Static fields and methods are part of the generic class, i.e. part of the "template" that specific object instances are created from. Non-static fields/methods are associated to a specific instance, or object. So, static fields/methods have no way of accessing the members of a specific instance because they can't know which instance you are refering to. Hope that helps!
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"