SlideShare a Scribd company logo
Dr Java Workshop – By Satyarth Gaur We will cover the following areas:  - Top 10 mistakes made by Java programmers – How to avoid them    - Core Java- Best Practices – This covers good and bad practices both - How to prepare for Java Interviews and Sun Java Exams
Top Ten Errors Java Programmers Make SATYARTH GAUR [email_address]
Accessing non-static member variables from static methods (such as main) public class StaticDemo { public String my_member_variable = "somedata"; public static void main (String args[]) { // Access a non-static member from static method System.out.println ("This generates a compiler error" + my_member_variable ); } }
Contd.. public class NonStaticDemo { public String my_member_variable = "somedata";   public static void main (String args[]) { NonStaticDemo demo = new NonStaticDemo();   // Access member variable of demo System.out.println ("This WON'T generate an error" + demo.my_member_variable ); } }
Mistyping the name of a method when overriding If you mistype the name, you're no longer overriding a method - you're creating an entirely new method, but with the same parameter and return type.
Comparison assignment (  = rather than == ) Fortunately, even if you don't spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : "Can't convert xxx to boolean", where xxx is a Java type that you're assigning instead of comparing.
Comparing two objects ( == instead of .equals) When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object. Ex. String Comparison String abc = "abc"; String def = "def";   // Bad way if ( (abc + def) == "abcdef" ) { ….. } // Good way if ( (abc + def).equals("abcdef") ) { ..... }
Confusion over passing by value, and passing by reference When you pass a primitive data type, such as a char, int, float, or double, to a function then you are  passing by value . That means that a copy of the data type is duplicated, and passed to the function. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only.
Contd.. When you pass a Java object, such as an array, a vector, or a string, to a function then you are  passing by reference .So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object's member variables will be permanent
Writing blank exception handlers public static void main(String args[]) {      try { // Your code goes here..      }      catch (Exception e)      { System.out.println ("Err - " + e );      } }
Forgetting that Java is zero-indexed If you've come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element's index is actually 0
Example Contd.. // Create an array of three strings String[] strArray = new String[3];   // First element's index is actually 0 strArray[0] = "First string";   // Second element's index is actually 1 strArray[1] = "Second string";   // Final element's index is actually 2 strArray[2] = "Third and final string";
Preventing concurrent access to shared variables by threads The simplest method is to make your variables private (but you do that already,  right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.
Contd.. public class MyCounter{ private int count = 0; // count starts at zero   public synchronized void setCount(int amount) {  count = amount; } public synchronized int getCount() { return count; }  }
Capitalization errors While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :-  all methods and member variables in the Java API begin with lowercase letters  all methods and member variables use capitalization where a new word begins e.g - getDoubleValue()
Capitalization errors While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :-  all methods and member variables in the Java API begin with lowercase letters  all methods and member variables use capitalization where a new word begins e.g - getDoubleValue()
Null pointers When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven't initialized an object, or you haven't checked the return value of a function.
Java  Best Practices Java Fundamentals & Object-Oriented Programming Dr Java Boot Camp – Satyarth Gaur
Bad Practices
Duplicate Code! Every time you need to make a change in the routine, you need to edit it in several places.  Don’t copy-paste code!
Accessible Fields Fields should always be private except for constants. Accessible fields cause tight coupling. Accessible fields are corruptible. If a field needs to be accessed, use “get” and “set” convention.
Using Magic Numbers Magic numbers are not readable for (int i = 1; i =< 52; i++) { j  =  i + randomInt(53 - i) – 1 swapEntries(i, j) } Replace with constants. final int DECKSIZE = 52; for (int i = 1; i =< DECKSIZE; i++) { j  =  i + randomInt(DECKSIZE + 1 - i) – 1 swapEntries(i, j) }
Temporary Fields If a variable need not be shared across methods, make it local. private int x; int method() { x = 0; // if you forget to initialize, you're dead ...  // do some stuff return x; } int method() { int x = 0; ...  // do some stuff return x; }
Initializing Strings with “new” Don’t: String str = new String(“This is bad.”); Do: String str = “This is good.”;
Using floats and doubles for currency calculations Binary numbers cannot exactly represent decimals. Use BigDecimal for currency calculations. ...using the constructor that takes a String as a parameter.
Returning null Causes NullPointerExceptions. Instead, return… empty objects custom-made “Null Objects”
 
 
Subclassing for Functionality Implementation inheritance is difficult to debug. Ask yourself: “Is this a kind of…?” Alternatives: Prefer interface inheritance. Prefer composition over inheritance.
Empty Catch Block No indication that an exception has occurred!
Using Exceptions Unexceptionally Use exceptions only for exceptional conditions. Bad: try { obj = arr[index]; } catch (ArrayIndexOutOfBoundsException) { // do something } Good: if (index < 0 || index >= arr.size()) { // do something } else { obj = arr[index]; }
Excessive Use of Switches Use of “if” and “switch” statements usually a sign of a breach of the “One Responsibility Rule”. Consider polymorphism instead.
instanceof If you’re using instanceof often, it probably means bad design. Consider adding an overridden method in supertype. instanceof should only be used  as validation prior to casting when you have to used a poorly-written library
Static Methods Static methods are.. ...procedural They break encapsulation - the method should be part of the object that needs it ...not polymorphic You can't have substitution/pluggability. You can't override a static method because the implementation is tied to the class it's defined in. Makes your code rigid, difficult to test.
System.exit Only use in stand-alone applications. For server applications, this might shut down the whole application container!
Good Practices
Validate Your Parameters The first lines of code in a method should check if the parameters are valid: void myMethod(String str, int index, Object[] arr) {  if (str == null) {   throw new IllegalArgumentException(“str cannot be null”); } if (index >= arr.size || index < 0) { throw new IllegalArgumentException(“index exceeds  bounds of array”); }  … }
Create Defensive Copies Create local copies, to prevent corruption. void myMethod (List listParameter) { List listCopy = new ArrayList(listParameter); listCopy.add(somevar); ... }
Modify Strings with StringBuilder String objects are immutable. You may think you’re changing a String, but you’re actually creating a new object. Danger of OutOfMemoryErrors. Poor peformance. StringBuilder is mutable. All changes are to the same object.
Favor Immutability If your objects don’t change… easier to debug. Fields are private and final. No setters, only getters.
Prefer  “final” for Variables Usually, variables / parameters do not need to change. Get into the habit of using  final  by default, and make a variable not final only when necessary.
Declare Variable Just Before Use Easier to read and refactor.
Initialize Variables Whenever Possible Helpful in debugging, makes it clear what initial value is. Makes sure you don’t use the variable before it’s ready for use.
Follow Code Conventions Improves readability For other programmers. For yourself. Readability means…  … less bugs. … easier to debug.
Refer to Objects by Interfaces Maintainability - changes in implementation need only be done at a single point in code Polymorphism – implementation can be set at runtime. // bad: ArrayList list = new ArrayList(); list.add(somevar); // good: List list = new ArrayList(); list.add(somevar);
Consider Using Enums instead of Constants Constants: Not typesafe No namespace You often need to prefix constants to avoid collisions Brittleness When you change the order, you need to change a lot of code. Printed values are uninformative
Close Your I/O Streams If you don’t close, other applications may not be able to use the resource. Close using the “finally” block in a try-catch.
Design Close to Domain Code is easily traceable if it is close to the business it is working for. If possible, name and group your packages according to the use cases. Easy to tell client %completion of feature. If user reports a bug, easier to find where it is.
If You Override equals() Override hashcode() Always make sure that when equals() returns true, the two object have the same hashcode. Otherwise, data structures like Sets and Maps may not work.
Write Self-Documenting Code Comments are important, but… … even without comments your code should be easily readable. Ask yourself: “If I removed my comments, can someone else still understand my code?”
Use Javadoc Liberally Provide as much documentation about your code as possible.
Bubble-Up Exceptions If code is not part of the user interface, it should not handle its own exceptions. It should be bubbled-up to presentation layer… Show a popup? Show an error page? Show a commandline message? Just log to an error log?
Best Sites for Java Examples,Code Samples,Tutorials and Interview Preparation www. roseindia .net www. vaannila .com www. java2s .com www. javaprepare .com  SCJP
Contd.. www. techinterviews .com http://www.jguru.com www.coderanch.com SCJP 5 /6 By Kathy Sierra -- E book http://javapractices.com

More Related Content

What's hot (20)

Presto best practices for Cluster admins, data engineers and analysts
Presto best practices for Cluster admins, data engineers and analystsPresto best practices for Cluster admins, data engineers and analysts
Presto best practices for Cluster admins, data engineers and analysts
Shubham Tagra
 
Apache Kylin
Apache KylinApache Kylin
Apache Kylin
BYOUNG GON KIM
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
Mihail Mateev
 
Introduction to Microsoft’s Hadoop solution (HDInsight)
Introduction to Microsoft’s Hadoop solution (HDInsight)Introduction to Microsoft’s Hadoop solution (HDInsight)
Introduction to Microsoft’s Hadoop solution (HDInsight)
James Serra
 
hive HBase Metastore - Improving Hive with a Big Data Metadata Storage
hive HBase Metastore - Improving Hive with a Big Data Metadata Storagehive HBase Metastore - Improving Hive with a Big Data Metadata Storage
hive HBase Metastore - Improving Hive with a Big Data Metadata Storage
DataWorks Summit/Hadoop Summit
 
Internal Hive
Internal HiveInternal Hive
Internal Hive
Recruit Technologies
 
[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례
[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례
[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례
Amazon Web Services Korea
 
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Simplilearn
 
BigQuery walk through.pptx
BigQuery walk through.pptxBigQuery walk through.pptx
BigQuery walk through.pptx
VikRam S
 
All Aboard the Databus
All Aboard the DatabusAll Aboard the Databus
All Aboard the Databus
Amy W. Tang
 
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Amazon Web Services Korea
 
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Altinity Ltd
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Arnab Mitra
 
Bridge to Cloud: Using Apache Kafka to Migrate to GCP
Bridge to Cloud: Using Apache Kafka to Migrate to GCPBridge to Cloud: Using Apache Kafka to Migrate to GCP
Bridge to Cloud: Using Apache Kafka to Migrate to GCP
confluent
 
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
Amazon Web Services Korea
 
Anti-spam techniques
Anti-spam techniquesAnti-spam techniques
Anti-spam techniques
Florin D. Tanasache
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
Dvir Volk
 
Neo4j in Production: A look at Neo4j in the Real World
Neo4j in Production: A look at Neo4j in the Real WorldNeo4j in Production: A look at Neo4j in the Real World
Neo4j in Production: A look at Neo4j in the Real World
Neo4j
 
ELK Stack
ELK StackELK Stack
ELK Stack
Eberhard Wolff
 
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
confluent
 
Presto best practices for Cluster admins, data engineers and analysts
Presto best practices for Cluster admins, data engineers and analystsPresto best practices for Cluster admins, data engineers and analysts
Presto best practices for Cluster admins, data engineers and analysts
Shubham Tagra
 
Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
Mihail Mateev
 
Introduction to Microsoft’s Hadoop solution (HDInsight)
Introduction to Microsoft’s Hadoop solution (HDInsight)Introduction to Microsoft’s Hadoop solution (HDInsight)
Introduction to Microsoft’s Hadoop solution (HDInsight)
James Serra
 
hive HBase Metastore - Improving Hive with a Big Data Metadata Storage
hive HBase Metastore - Improving Hive with a Big Data Metadata Storagehive HBase Metastore - Improving Hive with a Big Data Metadata Storage
hive HBase Metastore - Improving Hive with a Big Data Metadata Storage
DataWorks Summit/Hadoop Summit
 
[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례
[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례
[E-commerce & Retail Day] Amazon 혁신과 AWS Retail 사례
Amazon Web Services Korea
 
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Simplilearn
 
BigQuery walk through.pptx
BigQuery walk through.pptxBigQuery walk through.pptx
BigQuery walk through.pptx
VikRam S
 
All Aboard the Databus
All Aboard the DatabusAll Aboard the Databus
All Aboard the Databus
Amy W. Tang
 
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Amazon Web Services Korea
 
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Altinity Ltd
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Arnab Mitra
 
Bridge to Cloud: Using Apache Kafka to Migrate to GCP
Bridge to Cloud: Using Apache Kafka to Migrate to GCPBridge to Cloud: Using Apache Kafka to Migrate to GCP
Bridge to Cloud: Using Apache Kafka to Migrate to GCP
confluent
 
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
Amazon Web Services Korea
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
Dvir Volk
 
Neo4j in Production: A look at Neo4j in the Real World
Neo4j in Production: A look at Neo4j in the Real WorldNeo4j in Production: A look at Neo4j in the Real World
Neo4j in Production: A look at Neo4j in the Real World
Neo4j
 
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
confluent
 

Viewers also liked (7)

Java 8 DOs and DON'Ts - javaBin Oslo May 2015
Java 8 DOs and DON'Ts - javaBin Oslo May 2015Java 8 DOs and DON'Ts - javaBin Oslo May 2015
Java 8 DOs and DON'Ts - javaBin Oslo May 2015
Fredrik Vraalsen
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
arnold 7490
 
Java findamentals2
Java findamentals2Java findamentals2
Java findamentals2
Todor Kolev
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
arnold 7490
 
Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniques
LearnNowOnline
 
Manage Your Mesh
Manage Your MeshManage Your Mesh
Manage Your Mesh
Akana
 
Java 8 DOs and DON'Ts - javaBin Oslo May 2015
Java 8 DOs and DON'Ts - javaBin Oslo May 2015Java 8 DOs and DON'Ts - javaBin Oslo May 2015
Java 8 DOs and DON'Ts - javaBin Oslo May 2015
Fredrik Vraalsen
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals2
Java findamentals2Java findamentals2
Java findamentals2
Todor Kolev
 
Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniques
LearnNowOnline
 
Manage Your Mesh
Manage Your MeshManage Your Mesh
Manage Your Mesh
Akana
 
Ad

Similar to JAVA Tutorial- Do's and Don'ts of Java programming (20)

DotNet programming & Practices
DotNet programming & PracticesDotNet programming & Practices
DotNet programming & Practices
Dev Raj Gautam
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
guest5c8bd1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Vijay A Raj
 
Java tut1
Java tut1Java tut1
Java tut1
Ajmal Khan
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
Abdul Aziz
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Adhoura Academy
 
Javascript
JavascriptJavascript
Javascript
vikram singh
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Raghavan Mohan
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
Bernard Loire
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Javascript
JavascriptJavascript
Javascript
guest03a6e6
 
Java New Programming Features
Java New Programming FeaturesJava New Programming Features
Java New Programming Features
tarun308
 
Introduction to Intermediate Java
Introduction to Intermediate JavaIntroduction to Intermediate Java
Introduction to Intermediate Java
Philip Johnson
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
Intelligo Technologies
 
Java coding pitfalls
Java coding pitfallsJava coding pitfalls
Java coding pitfalls
tomi vanek
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
sholavanalli
 
Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit Testing
Mike Clement
 
Effective Java - Generics
Effective Java - GenericsEffective Java - Generics
Effective Java - Generics
Roshan Deniyage
 
DotNet programming & Practices
DotNet programming & PracticesDotNet programming & Practices
DotNet programming & Practices
Dev Raj Gautam
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Adhoura Academy
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Raghavan Mohan
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
Bernard Loire
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Java New Programming Features
Java New Programming FeaturesJava New Programming Features
Java New Programming Features
tarun308
 
Introduction to Intermediate Java
Introduction to Intermediate JavaIntroduction to Intermediate Java
Introduction to Intermediate Java
Philip Johnson
 
Java coding pitfalls
Java coding pitfallsJava coding pitfalls
Java coding pitfalls
tomi vanek
 
Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit Testing
Mike Clement
 
Effective Java - Generics
Effective Java - GenericsEffective Java - Generics
Effective Java - Generics
Roshan Deniyage
 
Ad

More from Keshav Kumar (8)

JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
Keshav Kumar
 
Sumit goyal, Promoter, PlanForMe.com
Sumit goyal, Promoter, PlanForMe.com Sumit goyal, Promoter, PlanForMe.com
Sumit goyal, Promoter, PlanForMe.com
Keshav Kumar
 
Alok Mittal, Managing Director, Canaan India
Alok Mittal, Managing Director, Canaan IndiaAlok Mittal, Managing Director, Canaan India
Alok Mittal, Managing Director, Canaan India
Keshav Kumar
 
Manish Vij, Co-founder, Quasar, Tyroo and Zoomtra
Manish Vij, Co-founder, Quasar, Tyroo and ZoomtraManish Vij, Co-founder, Quasar, Tyroo and Zoomtra
Manish Vij, Co-founder, Quasar, Tyroo and Zoomtra
Keshav Kumar
 
Pawan Gadia, Vice President, Ferns 'N' Petals
Pawan Gadia, Vice President, Ferns 'N' PetalsPawan Gadia, Vice President, Ferns 'N' Petals
Pawan Gadia, Vice President, Ferns 'N' Petals
Keshav Kumar
 
Manish Pathak, Brand Building
Manish Pathak, Brand BuildingManish Pathak, Brand Building
Manish Pathak, Brand Building
Keshav Kumar
 
Jatin Mahindra, Founder, InternetMafia
Jatin Mahindra, Founder, InternetMafiaJatin Mahindra, Founder, InternetMafia
Jatin Mahindra, Founder, InternetMafia
Keshav Kumar
 
Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.
Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.
Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.
Keshav Kumar
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
Keshav Kumar
 
Sumit goyal, Promoter, PlanForMe.com
Sumit goyal, Promoter, PlanForMe.com Sumit goyal, Promoter, PlanForMe.com
Sumit goyal, Promoter, PlanForMe.com
Keshav Kumar
 
Alok Mittal, Managing Director, Canaan India
Alok Mittal, Managing Director, Canaan IndiaAlok Mittal, Managing Director, Canaan India
Alok Mittal, Managing Director, Canaan India
Keshav Kumar
 
Manish Vij, Co-founder, Quasar, Tyroo and Zoomtra
Manish Vij, Co-founder, Quasar, Tyroo and ZoomtraManish Vij, Co-founder, Quasar, Tyroo and Zoomtra
Manish Vij, Co-founder, Quasar, Tyroo and Zoomtra
Keshav Kumar
 
Pawan Gadia, Vice President, Ferns 'N' Petals
Pawan Gadia, Vice President, Ferns 'N' PetalsPawan Gadia, Vice President, Ferns 'N' Petals
Pawan Gadia, Vice President, Ferns 'N' Petals
Keshav Kumar
 
Manish Pathak, Brand Building
Manish Pathak, Brand BuildingManish Pathak, Brand Building
Manish Pathak, Brand Building
Keshav Kumar
 
Jatin Mahindra, Founder, InternetMafia
Jatin Mahindra, Founder, InternetMafiaJatin Mahindra, Founder, InternetMafia
Jatin Mahindra, Founder, InternetMafia
Keshav Kumar
 
Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.
Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.
Ankur Dinesh Garg, CMD, Wirefoot India Technology Ltd.
Keshav Kumar
 

Recently uploaded (20)

Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 

JAVA Tutorial- Do's and Don'ts of Java programming

  • 1. Dr Java Workshop – By Satyarth Gaur We will cover the following areas:  - Top 10 mistakes made by Java programmers – How to avoid them    - Core Java- Best Practices – This covers good and bad practices both - How to prepare for Java Interviews and Sun Java Exams
  • 2. Top Ten Errors Java Programmers Make SATYARTH GAUR [email_address]
  • 3. Accessing non-static member variables from static methods (such as main) public class StaticDemo { public String my_member_variable = &quot;somedata&quot;; public static void main (String args[]) { // Access a non-static member from static method System.out.println (&quot;This generates a compiler error&quot; + my_member_variable ); } }
  • 4. Contd.. public class NonStaticDemo { public String my_member_variable = &quot;somedata&quot;;   public static void main (String args[]) { NonStaticDemo demo = new NonStaticDemo();   // Access member variable of demo System.out.println (&quot;This WON'T generate an error&quot; + demo.my_member_variable ); } }
  • 5. Mistyping the name of a method when overriding If you mistype the name, you're no longer overriding a method - you're creating an entirely new method, but with the same parameter and return type.
  • 6. Comparison assignment (  = rather than == ) Fortunately, even if you don't spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : &quot;Can't convert xxx to boolean&quot;, where xxx is a Java type that you're assigning instead of comparing.
  • 7. Comparing two objects ( == instead of .equals) When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object. Ex. String Comparison String abc = &quot;abc&quot;; String def = &quot;def&quot;;   // Bad way if ( (abc + def) == &quot;abcdef&quot; ) { ….. } // Good way if ( (abc + def).equals(&quot;abcdef&quot;) ) { ..... }
  • 8. Confusion over passing by value, and passing by reference When you pass a primitive data type, such as a char, int, float, or double, to a function then you are passing by value . That means that a copy of the data type is duplicated, and passed to the function. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only.
  • 9. Contd.. When you pass a Java object, such as an array, a vector, or a string, to a function then you are passing by reference .So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object's member variables will be permanent
  • 10. Writing blank exception handlers public static void main(String args[]) {     try { // Your code goes here..     }     catch (Exception e)     { System.out.println (&quot;Err - &quot; + e );     } }
  • 11. Forgetting that Java is zero-indexed If you've come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element's index is actually 0
  • 12. Example Contd.. // Create an array of three strings String[] strArray = new String[3];   // First element's index is actually 0 strArray[0] = &quot;First string&quot;;   // Second element's index is actually 1 strArray[1] = &quot;Second string&quot;;   // Final element's index is actually 2 strArray[2] = &quot;Third and final string&quot;;
  • 13. Preventing concurrent access to shared variables by threads The simplest method is to make your variables private (but you do that already,  right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.
  • 14. Contd.. public class MyCounter{ private int count = 0; // count starts at zero   public synchronized void setCount(int amount) { count = amount; } public synchronized int getCount() { return count; } }
  • 15. Capitalization errors While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :- all methods and member variables in the Java API begin with lowercase letters all methods and member variables use capitalization where a new word begins e.g - getDoubleValue()
  • 16. Capitalization errors While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :- all methods and member variables in the Java API begin with lowercase letters all methods and member variables use capitalization where a new word begins e.g - getDoubleValue()
  • 17. Null pointers When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven't initialized an object, or you haven't checked the return value of a function.
  • 18. Java Best Practices Java Fundamentals & Object-Oriented Programming Dr Java Boot Camp – Satyarth Gaur
  • 20. Duplicate Code! Every time you need to make a change in the routine, you need to edit it in several places. Don’t copy-paste code!
  • 21. Accessible Fields Fields should always be private except for constants. Accessible fields cause tight coupling. Accessible fields are corruptible. If a field needs to be accessed, use “get” and “set” convention.
  • 22. Using Magic Numbers Magic numbers are not readable for (int i = 1; i =< 52; i++) { j = i + randomInt(53 - i) – 1 swapEntries(i, j) } Replace with constants. final int DECKSIZE = 52; for (int i = 1; i =< DECKSIZE; i++) { j = i + randomInt(DECKSIZE + 1 - i) – 1 swapEntries(i, j) }
  • 23. Temporary Fields If a variable need not be shared across methods, make it local. private int x; int method() { x = 0; // if you forget to initialize, you're dead ... // do some stuff return x; } int method() { int x = 0; ... // do some stuff return x; }
  • 24. Initializing Strings with “new” Don’t: String str = new String(“This is bad.”); Do: String str = “This is good.”;
  • 25. Using floats and doubles for currency calculations Binary numbers cannot exactly represent decimals. Use BigDecimal for currency calculations. ...using the constructor that takes a String as a parameter.
  • 26. Returning null Causes NullPointerExceptions. Instead, return… empty objects custom-made “Null Objects”
  • 27.  
  • 28.  
  • 29. Subclassing for Functionality Implementation inheritance is difficult to debug. Ask yourself: “Is this a kind of…?” Alternatives: Prefer interface inheritance. Prefer composition over inheritance.
  • 30. Empty Catch Block No indication that an exception has occurred!
  • 31. Using Exceptions Unexceptionally Use exceptions only for exceptional conditions. Bad: try { obj = arr[index]; } catch (ArrayIndexOutOfBoundsException) { // do something } Good: if (index < 0 || index >= arr.size()) { // do something } else { obj = arr[index]; }
  • 32. Excessive Use of Switches Use of “if” and “switch” statements usually a sign of a breach of the “One Responsibility Rule”. Consider polymorphism instead.
  • 33. instanceof If you’re using instanceof often, it probably means bad design. Consider adding an overridden method in supertype. instanceof should only be used as validation prior to casting when you have to used a poorly-written library
  • 34. Static Methods Static methods are.. ...procedural They break encapsulation - the method should be part of the object that needs it ...not polymorphic You can't have substitution/pluggability. You can't override a static method because the implementation is tied to the class it's defined in. Makes your code rigid, difficult to test.
  • 35. System.exit Only use in stand-alone applications. For server applications, this might shut down the whole application container!
  • 37. Validate Your Parameters The first lines of code in a method should check if the parameters are valid: void myMethod(String str, int index, Object[] arr) { if (str == null) { throw new IllegalArgumentException(“str cannot be null”); } if (index >= arr.size || index < 0) { throw new IllegalArgumentException(“index exceeds bounds of array”); } … }
  • 38. Create Defensive Copies Create local copies, to prevent corruption. void myMethod (List listParameter) { List listCopy = new ArrayList(listParameter); listCopy.add(somevar); ... }
  • 39. Modify Strings with StringBuilder String objects are immutable. You may think you’re changing a String, but you’re actually creating a new object. Danger of OutOfMemoryErrors. Poor peformance. StringBuilder is mutable. All changes are to the same object.
  • 40. Favor Immutability If your objects don’t change… easier to debug. Fields are private and final. No setters, only getters.
  • 41. Prefer “final” for Variables Usually, variables / parameters do not need to change. Get into the habit of using final by default, and make a variable not final only when necessary.
  • 42. Declare Variable Just Before Use Easier to read and refactor.
  • 43. Initialize Variables Whenever Possible Helpful in debugging, makes it clear what initial value is. Makes sure you don’t use the variable before it’s ready for use.
  • 44. Follow Code Conventions Improves readability For other programmers. For yourself. Readability means… … less bugs. … easier to debug.
  • 45. Refer to Objects by Interfaces Maintainability - changes in implementation need only be done at a single point in code Polymorphism – implementation can be set at runtime. // bad: ArrayList list = new ArrayList(); list.add(somevar); // good: List list = new ArrayList(); list.add(somevar);
  • 46. Consider Using Enums instead of Constants Constants: Not typesafe No namespace You often need to prefix constants to avoid collisions Brittleness When you change the order, you need to change a lot of code. Printed values are uninformative
  • 47. Close Your I/O Streams If you don’t close, other applications may not be able to use the resource. Close using the “finally” block in a try-catch.
  • 48. Design Close to Domain Code is easily traceable if it is close to the business it is working for. If possible, name and group your packages according to the use cases. Easy to tell client %completion of feature. If user reports a bug, easier to find where it is.
  • 49. If You Override equals() Override hashcode() Always make sure that when equals() returns true, the two object have the same hashcode. Otherwise, data structures like Sets and Maps may not work.
  • 50. Write Self-Documenting Code Comments are important, but… … even without comments your code should be easily readable. Ask yourself: “If I removed my comments, can someone else still understand my code?”
  • 51. Use Javadoc Liberally Provide as much documentation about your code as possible.
  • 52. Bubble-Up Exceptions If code is not part of the user interface, it should not handle its own exceptions. It should be bubbled-up to presentation layer… Show a popup? Show an error page? Show a commandline message? Just log to an error log?
  • 53. Best Sites for Java Examples,Code Samples,Tutorials and Interview Preparation www. roseindia .net www. vaannila .com www. java2s .com www. javaprepare .com SCJP
  • 54. Contd.. www. techinterviews .com http://www.jguru.com www.coderanch.com SCJP 5 /6 By Kathy Sierra -- E book http://javapractices.com