Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to type @Override?

in most IDEs and editors there's no consensus as to how to ident the @Override. and it's not covered in the coding style for java http://www.oracle.com/technetwork/java/codeconvtoc-136057.html

i use exclusively vim and it creates a new indentation level. So i'm inclined to think that the correct is

@Override public boolean onTouch(View v, MotionEvent event) {

But every documentation shows

@Override
public boolean onTouch(View v, MotionEvent event) {

But most of the time, the editor autoidents that to

   @Override
      public boolean onTouch(View v, MotionEvent event) {

So, is there a 'correct' way? should i fix my java.vim syntax rules?

like image 733
gcb Avatar asked Nov 20 '10 04:11

gcb


People also ask

How do you override type in interface TypeScript?

Use the Omit utility type to override the type of an interface property, e.g. interface SpecificLocation extends Omit<Location, 'address'> {address: newType} . The Omit utility type constructs a new type by removing the specified keys from the existing type.

How do you override an interface in Java?

When a method in a subclass has the same name, same parameters or signature, and same return type(or sub-type) as a method in its super-class, then the method in the subclass is said to override the method in the super-class. Method overriding is one of the way by which java achieve Run Time Polymorphism.

How do I override a function in TypeScript?

To override a class method in TypeScript, extend from the parent class and define a method with the same name. Note that the types of the parameters and the return type of the method have to be compatible with the parent's implementation. Copied! class Parent { doMath(a: number, b: number): number { console.

What is as keyword in TypeScript?

The as keyword is a Type Assertion in TypeScript which tells the compiler to consider the object as another type than the type the compiler infers the object to be.


1 Answers

There's no one 'correct' way... all of them compile just fine, so they are all correct. Though, most of the cases you will see:

@Override
public boolean onTouch(View v, MotionEvent event) {

And, that's the way I prefer, because most programmers are used to that syntax, thus it's easier to read/understand for them.

like image 114
Cristian Avatar answered Oct 19 '22 18:10

Cristian