SlideShare a Scribd company logo
1 of 19
@Annotations
Before Java 5
• transient
• comments & java doc (@deprecated)
• interfaces
Where to use?
• classes
• fields
• methods
• packages
• variables
• types ( from Java 8)
@NotNull String array1 [][];
String array2 @NotNull [][];
String array3 [] @NotNull[];
String @NotNull[][] array4;
String @NotNull [] @NotNull[] array5;
@NotNull String @NotNull[] @NotNull[] array6;
@NonNull String name;
List<@NonNull String> names;
class UnmodifiableList<T> implements @Readonly List<@Readonly T> {...}
email = (@Email String) input; new @Information MyObject();
void doSomething() throws @ImportantForMe MyException { ... }
Use cases
• Information for the compiler
• Documentation
• Code generation
• Runtime processing
@Retention
• SOURCE
• CLASS
• RUNTIME
@Target
• ANNOTATION_TYPE
• CONSTRUCTOR
• FIELD
• LOCAL_VARIABLE
• METHOD
• PACKAGE
• TYPE_USE (TYPE_PARAMETER & TYPE)
• @Deprecated
• @Inherited
• @Deprecated
• @SuppressWarnings
• @Override
• @SafeVarargs
Java 8
• @Repeatable
• @FunctionalInterface
Example
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.PARAMETER})
public @interface Option {
String value();
Class type() default String.class;
boolean hasArg() default true;
boolean isRequired() default false;
}
@Demo
@Metaphor
public interface Life extends Box<Chocolate> {
}
@Oxymoron
public interface DisassemblerFactory {
Disassembler createDisassembler();
}
@LOL @Facepalm
@WTF("just use Collections.reverse()")
@Booyah
private static <T> void invertOrdering(List<T> list) {
for (int i = 0; i < list.size() / 2; i++) {
int j = list.size() - 1 - i;
T item1 = list.get(i);
T item2 = list.get(j);
list.set(i, item2);
list.set(j, item1);
}
}
@Magic
public static int negate(int n) {
return new Byte((byte) 0xFF).hashCode()
/ (int) (short) 'uFFFF' * ~0
* Character.digit ('0', 0) * n
* (Integer.MAX_VALUE * 2 + 1)
/ (Byte.MIN_VALUE >> 7) * (~1 | 1);
}
public void
setBonusMultiplier(@ThisHadBetterNotBe(NEGATIVE)
double multiplier) {
this.multiplier = multiplier;
}
@ThisWouldBeOneLineIn(
language = "haskell"
toWit = "product [1..n]")
public int factorial(int n) {
int fac = 1;
for (int i = 1; i <= n; i++) {
fac *= i;
}
return fac;
}
@Thanks

More Related Content

What's hot

Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structuresagorolabs
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets Hitesh-Java
 
Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...
Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...
Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...Lucidworks
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsPawanMM
 
Introduction on Data Structures
Introduction on Data StructuresIntroduction on Data Structures
Introduction on Data StructuresNanthini Kempaiyan
 
Java script prototype_hack
Java script prototype_hackJava script prototype_hack
Java script prototype_hackLearningTech
 
Reflection power pointpresentation ppt
Reflection power pointpresentation pptReflection power pointpresentation ppt
Reflection power pointpresentation pptRohit Vipin Mathews
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C SharpHarman Bajwa
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Hitesh-Java
 

What's hot (17)

Java interface
Java interfaceJava interface
Java interface
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...
Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...
Searching the Stuff of Life - BioSolr: Presented by Matt Pearce & Alan Woodwa...
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, Sets
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Introduction on Data Structures
Introduction on Data StructuresIntroduction on Data Structures
Introduction on Data Structures
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Java 8 ​and ​Best Practices
Java 8 ​and ​Best PracticesJava 8 ​and ​Best Practices
Java 8 ​and ​Best Practices
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Java script prototype_hack
Java script prototype_hackJava script prototype_hack
Java script prototype_hack
 
Java keywords
Java keywordsJava keywords
Java keywords
 
List classes
List classesList classes
List classes
 
Reflection power pointpresentation ppt
Reflection power pointpresentation pptReflection power pointpresentation ppt
Reflection power pointpresentation ppt
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C Sharp
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics
 

Viewers also liked

Challenge of ASEAN
Challenge of ASEANChallenge of ASEAN
Challenge of ASEANGus Agosto
 
Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...
Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...
Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...Andrew Jang
 
Dixien LLC's Commitment to Sustainability
Dixien LLC's Commitment to SustainabilityDixien LLC's Commitment to Sustainability
Dixien LLC's Commitment to SustainabilityDixien, LLC
 
Presentacion rodrigo campos
Presentacion rodrigo camposPresentacion rodrigo campos
Presentacion rodrigo camposrcz24
 
English Idioms and Expressions 2
English Idioms and Expressions 2English Idioms and Expressions 2
English Idioms and Expressions 2BigTickProductions
 
Race & Gender Discrimination in the U.S labor market
Race & Gender Discrimination in the U.S labor marketRace & Gender Discrimination in the U.S labor market
Race & Gender Discrimination in the U.S labor marketMoh'd A
 
Acta de Constitución de Podemos París
Acta de Constitución de Podemos ParísActa de Constitución de Podemos París
Acta de Constitución de Podemos ParísPodemos París
 
Labour problem,industrailization, uranization
Labour problem,industrailization, uranizationLabour problem,industrailization, uranization
Labour problem,industrailization, uranizationStudent
 

Viewers also liked (14)

How to Teach the Haggadah
How to Teach the HaggadahHow to Teach the Haggadah
How to Teach the Haggadah
 
Challenge of ASEAN
Challenge of ASEANChallenge of ASEAN
Challenge of ASEAN
 
Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...
Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...
Applying for Jobs in British Columbia's Public Schools | October 2013 | Make ...
 
雲端教戰
雲端教戰雲端教戰
雲端教戰
 
Dixien LLC's Commitment to Sustainability
Dixien LLC's Commitment to SustainabilityDixien LLC's Commitment to Sustainability
Dixien LLC's Commitment to Sustainability
 
Presentacion rodrigo campos
Presentacion rodrigo camposPresentacion rodrigo campos
Presentacion rodrigo campos
 
English Idioms and Expressions 2
English Idioms and Expressions 2English Idioms and Expressions 2
English Idioms and Expressions 2
 
Marketing Plan MyAzaria
Marketing Plan MyAzariaMarketing Plan MyAzaria
Marketing Plan MyAzaria
 
Race & Gender Discrimination in the U.S labor market
Race & Gender Discrimination in the U.S labor marketRace & Gender Discrimination in the U.S labor market
Race & Gender Discrimination in the U.S labor market
 
Sesión 1.3. prevención de iaas
Sesión 1.3.   prevención de iaasSesión 1.3.   prevención de iaas
Sesión 1.3. prevención de iaas
 
Acta de Constitución de Podemos París
Acta de Constitución de Podemos ParísActa de Constitución de Podemos París
Acta de Constitución de Podemos París
 
Labour problem,industrailization, uranization
Labour problem,industrailization, uranizationLabour problem,industrailization, uranization
Labour problem,industrailization, uranization
 
Lesson plan
Lesson planLesson plan
Lesson plan
 
Physiocarcy
PhysiocarcyPhysiocarcy
Physiocarcy
 

Similar to Annotations

Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_reviewEdureka!
 
arrays in c# including Classes handling arrays
arrays in c#  including Classes handling arraysarrays in c#  including Classes handling arrays
arrays in c# including Classes handling arraysJayanthiM19
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3Ahmet Bulut
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptxssuserb1a18d
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basicsLovelitJose
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern JavaSina Madani
 
Tuples, Dicts and Exception Handling
Tuples, Dicts and Exception HandlingTuples, Dicts and Exception Handling
Tuples, Dicts and Exception HandlingPranavSB
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryPray Desai
 

Similar to Annotations (20)

ITFT - Java
ITFT - JavaITFT - Java
ITFT - Java
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
 
Java
Java Java
Java
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
 
arrays in c# including Classes handling arrays
arrays in c#  including Classes handling arraysarrays in c#  including Classes handling arrays
arrays in c# including Classes handling arrays
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern Java
 
Tuples, Dicts and Exception Handling
Tuples, Dicts and Exception HandlingTuples, Dicts and Exception Handling
Tuples, Dicts and Exception Handling
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
#_ varible function
#_ varible function #_ varible function
#_ varible function
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Java introduction
Java introductionJava introduction
Java introduction
 
Javascript
JavascriptJavascript
Javascript
 
Core java concepts
Core java conceptsCore java concepts
Core java concepts
 
C Sharp Course 101.5
C Sharp Course 101.5C Sharp Course 101.5
C Sharp Course 101.5
 
Python with data Sciences
Python with data SciencesPython with data Sciences
Python with data Sciences
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

Annotations