Java Topics
HubJava Collections FrameworkCollections Practice ProgramsComparable vs ComparatorGenericsIteratorArrayListLinkedListStackVectorHashMapHashtableLinkedHashMapTreeMapArrayDequeDeque Double-Ended QueuePriorityQueueHashSetLinkedHashSetTreeSetAdapter PatternBuilder PatternFactory PatternMVC PatternObserver PatternSingleton PatternDynamic ProgrammingGraphHashingHeapLinked List DSAQueue DSARecursionSearching AlgorithmsSorting AlgorithmsStack DSATime ComplexityTreesException Handling Best PracticesCustom ExceptionException Hierarchyfinally BlockException Handlingthrow aur throwstry-catchBuffered StreamsByte StreamsCharacter StreamsDeserializationFile ClassJava NIO New I/OSerializationArrays in JavaArray OperationsArray Practice ProgramsArray Interview QuestionsJagged ArrayMulti-Dimensional ArraysOne Dimensional Arraybreak aur continuedo-while Loopfor Loopif-else StatementsNested Loopsswitch-case Statementwhile LoopJava Compilation ProcessJava ki FeaturesPehla Java ProgramHistory of JavaJava EditionsJava Program StructureJDK, JRE aur JVMJava Kya Hai?Immutable StringsString Class in JavaString Interview QuestionsString MethodsString Practice ProgramsStringBufferStringBuilderComments in JavaData Types in JavaIdentifiers in JavaInput & Output in JavaJava KeywordsOperators in JavaType Casting in JavaVariables in JavaJava Coding Interview QuestionsCollections Interview QuestionsCore Java Interview QuestionsJDBC Interview QuestionsMultithreading Interview QuestionsOOPs Interview QuestionsSpring Framework Interview QuestionsJava 8 Date/Time APIDefault aur Static Methods in InterfaceFunctional InterfaceLambda ExpressionMethod ReferenceOptional ClassStream APIBatch ProcessingCallableStatementJDBC ArchitectureJDBC — Java Database ConnectivityJDBC Practice ProjectsMySQL ConnectionPreparedStatementResultSetStatement InterfaceTransaction ManagementCreating ThreadsDaemon ThreadExecutor FrameworkInter-Thread CommunicationMultithreading Practice ProgramsRunnable InterfaceSynchronizationThread ClassMultithreading IntroductionThread Life CycleThread PriorityJava Cheat SheetImportant Formulas & Key ConceptsImportant Java ProgramsJava Quick RevisionAbstract ClassAbstractionAnonymous ClassClass and ObjectConstructorEncapsulationInheritanceInner ClassInterfaceMethod OverloadingMethod OverridingObject ClassObject CloningObject-Oriented Programming OOPPolymorphismstatic Keywordsuper Keywordthis KeywordWrapper ClassesArray Practice ProgramsBasic Java Practice ProgramsCollection Practice ProgramsJDBC Practice ProgramsMultithreading Practice ProgramsOOPs Practice ProgramsPlacement Coding QuestionsString Practice ProgramsBanking SystemChat ApplicationE-Commerce Backend — Spring Boot REST APIEmployee Management SystemLibrary Management SystemSpring Boot Fullstack ProjectStudent Management SystemCookies in ServletExpression Language ELGenericServletHttpServletJavaServer Pages JSPJSP TagsMVC ArchitectureHttpServletRequest & HttpServletResponseServlet IntroductionServlet Life CycleSession TrackingDependency InjectionSpring BeansSpring CoreSpring FrameworkAPI GatewaySpring Cloud Config ServerDocker DeploymentEureka Server — Service DiscoverySpring Boot CRUD ApplicationException Handling in Spring BootJWT AuthenticationREST API in Spring BootSpring SecuritySpring BootSpring Data JPAValidation in Spring Boot
Important Formulas & Key Concepts
Last Updated : 26 May, 2026
title: Important Formulas and Concepts
Notes52 words12 headingsExamples included
title: Important Formulas and Concepts description: Java ke important formulas aur key concepts
Data Type Ranges
| byte | -128 to 127 (2^7) |
| short | -32,768 to 32,767 (2^15) |
| int | -2,147,483,648 to 2,147,483,647 (2^31) |
| long | -9,223,372,036... to 9,223,372,036... (2^63) |
| float | ~1.4e-45 to ~3.4e38 (32-bit IEEE 754) |
| double | ~4.9e-324 to ~1.8e308 (64-bit IEEE 754) |
| char | 0 to 65,535 (Unicode) |
String Pool Formula
| String s1 = "hello" | Pool mein store |
| String s2 = "hello" | Same pool object (s1 == s2 → true) |
| String s3 = new String("hello") | Heap mein naya object (s1 == s3 → false) |
| s1.equals(s3) | true (content same) |
Array Size Formula
Total elements = rows × columns (2D array)
Index range = 0 to (length - 1)
Last index = array.length - 1
Middle index = (lo + hi) / 2 OR lo + (hi - lo) / 2 (overflow safe)
Time Complexity Formulas
| O(1) | Constant → Array index access, HashMap get |
| O(log n) | Binary search → Each step half karta hai: log₂(n) steps |
| O(n) | Linear → One loop |
| O(n log n) | Merge sort → n levels × log n splits |
| O(n²) | Quadratic → Nested loops |
| O(2ⁿ) | Exponential → Fibonacci recursive |
Sorting Formulas
Bubble Sort comparisons = n(n-1)/2
Sum of 1 to n = n(n+1)/2
Binary Search steps = log₂(n) (max comparisons)
Thread Priority Range
MIN_PRIORITY = 1
NORM_PRIORITY = 5 (default)
MAX_PRIORITY = 10
HashMap Internal Formula
Default capacity = 16
Default load factor = 0.75
Resize threshold = capacity × load factor = 16 × 0.75 = 12
After resize = capacity × 2 = 32
Hash index = hashCode % capacity
StringBuilder Capacity Formula
Default capacity = 16
After append = if (length > capacity) → new capacity = (old × 2) + 2
Collection Initial Capacities
ArrayList default capacity = 10 (grows 50%: newSize = oldSize + oldSize/2)
HashMap default capacity = 16 (grows 2x when load factor exceeded)
HashSet default capacity = 16
Exception Hierarchy
Throwable
├── Error (unrecoverable)
│ └── OutOfMemoryError, StackOverflowError
└── Exception
├── IOException (checked)
├── SQLException (checked)
└── RuntimeException (unchecked)
├── NullPointerException
├── ArrayIndexOutOfBoundsException
└── ClassCastException
JVM Memory Areas
| Heap | Objects store hote hain (GC yahan kaam karta hai) |
| Stack | Method frames, local variables |
| Method Area | Class definitions, static variables |
| PC Register | Current instruction address |
| Native Stack | Native method calls |
Integer Cache Range
Integer -128 to 127 → Cached (same object milta hai)
Integer 128+ → New object banta hai
Always use .equals() for Integer comparison
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Important Formulas & Key Concepts.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Java topic.
Search Terms
java, java programming, core java, java master course, java notes, master, course, notes
Related Java Topics
Continue learning this concept
NotesImportant Java Programstitle: Important ProgramsNotesJava Cheat Sheettitle: Java Cheat SheetNotesJava Quick Revisiontitle: Quick Revision NotesCollections FrameworkJava Collections Frameworktitle: Collections Framework OverviewCollections FrameworkCollections Practice Programstitle: Collections ProgramsCollections FrameworkComparable vs Comparatortitle: Comparable vs Comparator