Java Tutorial
IntroductionEnvironment SetupIDEBuild ManagementLanguage SpecificationBasic ProgramVariablesData TypesPackagesModifiersConditionalsLoopsObject OrientedClassesSuperInterfacesEnumStatic importInheritanceAbstractionEncapsulationPolymorphismBoxing & UnboxingConversion Formatting numbers Arrays Command line arguments in java Variable Number of arguments in Java Exception handling in Java String handling in Java StringBuffer and StringBuilder in Java Mathematical Operations in Java Date and Time in Java Regular expressions in Java Input output programming in Java File Handling Nested Classes Collections Generics Serialization Socket programming Multi-Threading Annotations Lambda Expressions Reflections in Java Singleton class in Java Runtime Class in JavaHow to load resource in JavaHow to load properties file in JavaAdvanced
Log4j – Logging framework in JavaInterview Questions in JavaAnnotations in Java
Annotations can be used to give special instructions to program in Java. There are 3 types of annotations in Java.- Compiler Annotations
- Build time Annotations
- Runtime Annotations (e.g. @Test in Junit Framework)
- @Override
- @SuppressWarnings
- @Deprecated
package annotations;
import jdk.nashorn.internal.ir.annotations.Ignore;
import org.junit.Test;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by ssalunke on 13/04/2016.
*/
public class TestAnnotations {
@Test(timeout = 1000) @Ignore
public void test(){
System.out.println("Standard JUnit Test annotation");
}
@MyTest(myIgnore = "Yes",myPriority = 2)
public void testMyAnnotation(){
System.out.println("Custom Annotation ");
}
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD,ElementType.CONSTRUCTOR})
@interface MyTest {
String myIgnore() default "";
int myPriority() default 1;
}
Web development and Automation testing
solutions delivered!!