#- Map: HashMap
Explore tagged Tumblr posts
Text
JavaCollections: Your Data, Your Way
Master the art of data structures:
List: ArrayList, LinkedList
Set: HashSet, TreeSet
Queue: PriorityQueue, Deque
Map: HashMap, TreeMap
Pro tips:
Use generics for type safety
Choose the right collection for your needs
Leverage stream API for elegant data processing
Collections: Because arrays are so last century.
#JavaCollections: Your Data#Your Way#Master the art of data structures:#- List: ArrayList#LinkedList#- Set: HashSet#TreeSet#- Queue: PriorityQueue#Deque#- Map: HashMap#TreeMap#Pro tips:#- Use generics for type safety#- Choose the right collection for your needs#- Leverage stream API for elegant data processing#Collections: Because arrays are so last century.#JavaProgramming#DataStructures#CodingEfficiency
2 notes
·
View notes
Text

What does the JDBC ResultSet interface? . . . . For more questions about Java https://bit.ly/465SkSw Check the above link
#resultset#rowset#drivermanager#preparedstatement#execute#executequery#executeupdate#array#arraylist#jdbc#hashcode#collection#comparator#comparable#blockingqueue#hashSet#treeSet#set#map#hashMap#computersciencemajor#javatpoint
0 notes
Text
Node based coding... in Java. It has taken a few weeks, but I have the system done.
As well, amazingly commented code base that explains what about everything does.
And everything being ran as functions defined in a registry! Hi NeoForge
I think the system for reading the graph of nodes is unique also! Since, I have had... a bad time with the JavaStackLimit, I decided to have the core of my system be around avoiding it as much as possible. So instead of recursively asking what node connects to what node, 2 stacks are made, 1 holds what will be running after it is done finding, the other holds a search stack. Meaning it can get any part of the graph, and it should just find the right order of things.
And! Since the read method is different from the run method, I can hypothetically just read and serialize the given node stack, making it persist between restarts.
The running system is a little more complex than just a search.
First it starts a `for` loop of the stack of nodes, then it starts making the inputs for the node. It checks if the node has any inputs, if so, check the output type of the previous node, if it is equal to this node's input (or if this node's input takes in ANY) then dont error. After not erroring, add to the input array; or, if the input was not connected to anything, give it null. Repeat the last steps until there are no inputs left for this node.
Next, it runs the node. It does this by getting all the registered nodes (in a HashMap for some extra speed), then finding the associated function with that Key. Then it tries to run the function with the given inputs. If the function does not crash, it checks if the function outputted anything, if so put that into the Environment's HashMap of all node outputs. Finally, repeat the last 2 paragraphs until there are no more nodes. Then clear the output map, so there is no "bleed over"
So TLDR: get all nodes into a stack (avoiding duplicates), then run a For Each over that stack, check if the type of inputs/outputs match, if so run the node and put its outputs onto a HashMap of outputs so it only needs to be run once.
And ALL OF THIS just to be put into a silly minecraft mod. But hey, at least I am having fun!
#long post#my art#modded minecraft#coding#Java#minecraft java#minecraft modding#minecraft modding at its finest yall#there is also a lot more in this mod I have not shown in Tumblr yet#If any of yall have any questions#my DMs/Askbox is open!
10 notes
·
View notes
Text
100 days of code - day 10
Hi :)
Today I finished the chapter 7 and 8 from the rust book.
Chapter 7 teaches about modules, that are basically containers that I can use to organize the code, how to use external packages and the conventions for separating modules in different files. It was quite a "boring" chapter, and I get distracted a lot, but I managed to finish.
Chapter 8 show us some useful data structures, that are keep in the std::collections module from rust. They are, Vectors, Strings and HashMap.
Vector is like an array, but with the plus that they are resizable, and can grow and shrink. And also have a lot of useful methods.
Strings are strings. Leaned about some handy methods and macros to manipulate strings.
HashMap is a data structure that maps keys to values with a hashing function. So it is efficient to insert and retrieve data from a hash map.
Also, I did some exercises on rustlings about vectors, ownership and borrowing.
That's it 😊
#day 10#100 days of code#100daysofcode#codeblr#programming#progblr#studyblr#computer science#Rust#1000 hours#code#100 days of productivity#100 days of studying#100 days challenge#tech
26 notes
·
View notes
Text
🚀 Day 1: Kicking Off My Programming & Study Blog!
Welcome to my first post in what I hope will be a long series documenting my journey through programming in Rust, learning algorithms and trying to build some projects. I’ve been learning Rust for couple of weeks and from today I started a course on algorithms MIT's 6.006 Introduction to Algorithms. I felt like sharing my progress here to motivate my self to stay consistent.
🦀 Rust Exercise: Vectors Maps & HashMap
Today, I finished a Rust exercise from the Rust Book form chapter 8. With the use of Hashmap and Vector I had to create create a way for users to add employees to departments (e.g., "Add Sally to Engineering") and retrieve a sorted list of everyone in a department or the whole company.
Core Components: I used a HashMap to store departments and Vec for employee names within each department.
Challenge: I hit a wall when trying to retrieve the list of employees in a department. After an hour of debugging, I finally realized I wasn’t trimming the key string I was using to query the hash map! The newline "\n" was still in the string, causing it not to match any key in the map.
Takeaway: Print the bloody input next time! It would have saved me a lot of time and frustration. I am bad at debugging, Lesson learned.
📘MIT 6.006 Introduction to Algorithms
I also started MIT’s Introduction to Algorithms course and watched Lecture 1. It was an introductory lecture. I have tried learning Algorithms couple of times so I have been through introductions a lot. I hope this time I'll go further.
🔍 What’s Next
Starting both Rust and algorithms simultaneously is exciting, I’m ready for the challenge. For tomorrow, I'm planning to complete more chapters from The Rust Book, Next one is about Error handling and then I'll tackle the next lecture in the MIT series.
Feel free to follow along if you’re on a similar journey, and let’s level up together!
#studyblr#codeblr#coding#programming#rust#computer science#software development#100 days of productivity#100 days of studying#learn to code
2 notes
·
View notes
Text
Slice it Up
Most big problems are made of other, smaller problems.
The life expectancy map I’m building has,
1) Setup. Import all the map data. Translate the map data (as necessary, parse strings from CSV into floats or ints). Initialize the constructors. Set draw parameters.
2) Draw. On one layer, draw the base map. Next run a for-each loop through the translated hashmap and set colors based on values. Recolor segments of the map (fortunately the map program we’re using already has zones for countries laid out so when we tell it to color France it knows which pixels we’re talking about)
I felt sorry for our instructors, having to do a lecture talking about both maps with countries on them and Maps - that is, key-value pairs for data processing. Anyway.
One really convenient part of the entire process is that this procedure
Outline the project
Build out pieces of the outline one by one
Split them into smaller slices if they’re still too complicated
That doesn’t just make it easier on your end, keeping track of how much of the project you’ve done. It also makes for code that’s cleaner, easier to comprehend, easier to bug-hunt in, and easier to maintain or upgrade.
2 notes
·
View notes
Video
youtube
LEETCODE PROBLEMS 1-100 . C++ SOLUTIONS
Arrays and Two Pointers 1. Two Sum – Use hashmap to find complement in one pass. 26. Remove Duplicates from Sorted Array – Use two pointers to overwrite duplicates. 27. Remove Element – Shift non-target values to front with a write pointer. 80. Remove Duplicates II – Like #26 but allow at most two duplicates. 88. Merge Sorted Array – Merge in-place from the end using two pointers. 283. Move Zeroes – Shift non-zero values forward; fill the rest with zeros.
Sliding Window 3. Longest Substring Without Repeating Characters – Use hashmap and sliding window. 76. Minimum Window Substring – Track char frequency with two maps and a moving window.
Binary Search and Sorted Arrays 33. Search in Rotated Sorted Array – Modified binary search with pivot logic. 34. Find First and Last Position of Element – Binary search for left and right bounds. 35. Search Insert Position – Standard binary search for target or insertion point. 74. Search a 2D Matrix – Binary search treating matrix as a flat array. 81. Search in Rotated Sorted Array II – Extend #33 to handle duplicates.
Subarray Sums and Prefix Logic 53. Maximum Subarray – Kadane’s algorithm to track max current sum. 121. Best Time to Buy and Sell Stock – Track min price and update max profit.
Linked Lists 2. Add Two Numbers – Traverse two lists and simulate digit-by-digit addition. 19. Remove N-th Node From End – Use two pointers with a gap of n. 21. Merge Two Sorted Lists – Recursively or iteratively merge nodes. 23. Merge k Sorted Lists – Use min heap or divide-and-conquer merges. 24. Swap Nodes in Pairs – Recursively swap adjacent nodes. 25. Reverse Nodes in k-Group – Reverse sublists of size k using recursion. 61. Rotate List – Use length and modulo to rotate and relink. 82. Remove Duplicates II – Use dummy head and skip duplicates. 83. Remove Duplicates I – Traverse and skip repeated values. 86. Partition List – Create two lists based on x and connect them.
Stack 20. Valid Parentheses – Use stack to match open and close brackets. 84. Largest Rectangle in Histogram – Use monotonic stack to calculate max area.
Binary Trees 94. Binary Tree Inorder Traversal – DFS or use stack for in-order traversal. 98. Validate Binary Search Tree – Check value ranges recursively. 100. Same Tree – Compare values and structure recursively. 101. Symmetric Tree – Recursively compare mirrored subtrees. 102. Binary Tree Level Order Traversal – Use queue for BFS. 103. Binary Tree Zigzag Level Order – Modify BFS to alternate direction. 104. Maximum Depth of Binary Tree – DFS recursion to track max depth. 105. Build Tree from Preorder and Inorder – Recursively divide arrays. 106. Build Tree from Inorder and Postorder – Reverse of #105. 110. Balanced Binary Tree – DFS checking subtree heights, return early if unbalanced.
Backtracking 17. Letter Combinations of Phone Number – Map digits to letters and recurse. 22. Generate Parentheses – Use counts of open and close to generate valid strings. 39. Combination Sum – Use DFS to explore sum paths. 40. Combination Sum II – Sort and skip duplicates during recursion. 46. Permutations – Swap elements and recurse. 47. Permutations II – Like #46 but sort and skip duplicate values. 77. Combinations – DFS to select combinations of size k. 78. Subsets – Backtrack by including or excluding elements. 90. Subsets II – Sort and skip duplicates during subset generation.
Dynamic Programming 70. Climbing Stairs – DP similar to Fibonacci sequence. 198. House Robber – Track max value including or excluding current house.
Math and Bit Manipulation 136. Single Number – XOR all values to isolate the single one. 169. Majority Element – Use Boyer-Moore voting algorithm.
Hashing and Frequency Maps 49. Group Anagrams – Sort characters and group in hashmap. 128. Longest Consecutive Sequence – Use set to expand sequences. 242. Valid Anagram – Count characters using map or array.
Matrix and Miscellaneous 11. Container With Most Water – Two pointers moving inward. 42. Trapping Rain Water – Track left and right max heights with two pointers. 54. Spiral Matrix – Traverse matrix layer by layer. 73. Set Matrix Zeroes – Use first row and column as markers.
This version is 4446 characters long. Let me know if you want any part turned into code templates, tables, or formatted for PDF or Markdown.
0 notes
Text
HashMap Related Interview Questions And Answers
These are the some best of HashMap related interview questions and answers for both freshers and experienced Java professionals. I hope they will be helpful for your technical interview. Java HashMap Interview Questions And Answers : 1) What is HashMap in Java? HashMap is a class in Java which implements Map interface. It is a data structure which holds the data as key-value pairs for…
View On WordPress
0 notes
Text
📚 Comparing Java Collections: Which Data Structure Should You Use?
If you're diving into Core Java, one thing you'll definitely bump into is the Java Collections Framework. From storing a list of names to mapping users with IDs, collections are everywhere. But with all the options like List, Set, Map, and Queue—how do you know which one to pick? 🤯
Don’t worry, I’ve got you covered. Let’s break it down in simple terms, so you can make smart choices for your next Java project.
🔍 What Are Java Collections, Anyway?
The Java Collection Framework is like a big toolbox. Each tool (or data structure) helps you organize and manage your data in a specific way.
Here's the quick lowdown:
List – Ordered, allows duplicates
Set – Unordered, no duplicates
Map – Key-value pairs, keys are unique
Queue – First-In-First-Out (FIFO), or by priority
📌 When to Use What? Let’s Compare!
📝 List – Perfect for Ordered Data
Wanna keep things in order and allow duplicates? Go with a List.
Popular Types:
ArrayList – Fast for reading, not so much for deleting/inserting
LinkedList – Good for frequent insert/delete
Vector – Thread-safe but kinda slow
Stack – Classic LIFO (Last In, First Out)
Use it when:
You want to access elements by index
Duplicates are allowed
Order matters
Code Snippet:
java
🚫 Set – When You Want Only Unique Stuff
No duplicates allowed here! A Set is your go-to when you want clean, unique data.
Popular Types:
HashSet – Super fast, no order
LinkedHashSet – Keeps order
TreeSet – Sorted, but a bit slower
Use it when:
You care about uniqueness
You don’t mind the order (unless using LinkedHashSet)
You want to avoid duplication issues
Code Snippet:
java
🧭 Map – Key-Value Power Couple
Think of a Map like a dictionary. You look up values by their unique keys.
Popular Types:
HashMap – Fastest, not ordered
LinkedHashMap – Keeps insertion order
TreeMap – Sorted keys
ConcurrentHashMap – Thread-safe (great for multi-threaded apps)
Use it when:
You need to pair keys with values
You want fast data retrieval by key
Each key should be unique
Code Snippet:
java
⏳ Queue – For First-Come-First-Serve Vibes
Need to process tasks or requests in order? Use a Queue. It follows FIFO, unless you're working with priorities.
Popular Types:
LinkedList (as Queue) – Classic FIFO
PriorityQueue – Sorted based on priority
ArrayDeque – No capacity limit, faster than LinkedList
ConcurrentLinkedQueue – Thread-safe version
Use it when:
You’re dealing with task scheduling
You want elements processed in the order they come
You need to simulate real-life queues (like print jobs or tasks)
Code Snippet:
java
🧠 Cheat Sheet: Pick Your Collection Wisely
⚙️ Performance Talk: Behind the Scenes
💡 Real-Life Use Cases
Use ArrayList for menu options or dynamic lists.
Use HashSet for email lists to avoid duplicates.
Use HashMap for storing user profiles with IDs.
Use Queue for task managers or background jobs.
🚀 Final Thoughts: Choose Smart, Code Smarter
When you're working with Java Collections, there’s no one-size-fits-all. Pick your structure based on:
What kind of data you’re working with
Whether duplicates or order matter
Performance needs
The better you match the collection to your use case, the cleaner and faster your code will be. Simple as that. 💥
Got questions? Or maybe a favorite Java collection of your own? Drop a comment or reblog and let’s chat! ☕💻
If you'd like me to write a follow-up on concurrent collections, sorting algorithms, or Java 21 updates, just say the word!
✌️ Keep coding, keep learning! For More Info : Core Java Training in KPHB For UpComing Batches : https://linktr.ee/NIT_Training
#Java#CoreJava#JavaProgramming#JavaCollections#DataStructures#CodingTips#DeveloperLife#LearnJava#ProgrammingBlog#TechBlog#SoftwareEngineering#JavaTutorial#CodeNewbie#JavaList#JavaSet#JavaMap#JavaQueue#CleanCode#ObjectOrientedProgramming#BackendDevelopment#ProgrammingBasics
0 notes
Text
Java Count Character Frequency in String – Different Ways
java count character frequency in string:
Using a HashMap (Traditional approach)
Using Java 8 Streams (Modern approach)
Using Arrays for fixed character sets
Here's the HashMap approach:
java
Copy
Edit
import java.util.HashMap;
import java.util.Map;
public class CharFrequency {
public static void main(String[] args) {
String str = "hello world";
Map<Character, Integer> freqMap = new HashMap<>();
for (char ch : str.toCharArray()) {
freqMap.put(ch, freqMap.getOrDefault(ch, 0) + 1);
}
System.out.println(freqMap);
}
}
It efficiently counts character occurrences using a HashMap. The output would be something like:
Copy
Edit
{h=1, e=1, l=3, o=2, w=1, r=1, d=1}
0 notes
Text

What is the role of the JDBC DriverManager class? . . . . For more questions about Java https://bit.ly/465SkSw Check the above link
#resultset#rowset#drivermanager#preparedstatement#execute#executequery#executeupdate#array#arraylist#jdbc#hashcode#collection#comparator#comparable#blockingqueue#hashSet#treeSet#set#map#hashMap#computersciencemajor#javatpoint
0 notes
Text
What is the Java collection framework- 2025
The Java Collection Framework is a group of classes and interfaces that provide various data structures and algorithms for storing and manipulating data efficiently. It includes interfaces like List, Set, and Map, and implementations such as ArrayList, HashSet, and HashMap. The framework helps developers handle data more effectively, with built-in methods for searching, sorting, and modifying collections.
0 notes
Text
Assignment 2: HashMap
According to veteran C++ programmers, there are two projects which bring together all the knowledge that a profcient C++ programmer should have: Implementing a STL-compliant template class; and Implement a macro to hash string literals at compile-time. In this assignment, we will be putting #1 on your resume by building a STL-compliant HashMap. Recall that the Map abstract data type stores key…
0 notes
Text
Key Concepts to Review Before Your Java Interview
youtube
Java interviews can be both challenging and rewarding, often acting as a gateway to exciting roles in software development. Whether you're applying for an entry-level position or an advanced role, being well-prepared with core concepts is essential. In this guide, we’ll cover key topics to review before your Java interview, ensuring you're confident and ready to impress. Additionally, don't forget to check out this detailed video guide to strengthen your preparation with visual explanations and code demonstrations.
1. Object-Oriented Programming (OOP) Concepts
Java is known for its robust implementation of OOP principles. Before your interview, make sure to have a firm grasp on:
Classes and Objects: Understand how to create and use objects.
Inheritance: Review how subclasses inherit from superclasses, and when to use inheritance.
Polymorphism: Know the difference between compile-time (method overloading) and runtime polymorphism (method overriding).
Abstraction and Encapsulation: Be prepared to explain how and why they are used in Java.
Interview Tip: Be ready to provide examples of how you’ve used these concepts in your projects or coding exercises.
2. Core Java Concepts
In addition to OOP, there are foundational Java topics you need to master:
Data Types and Variables: Understand primitive types (int, double, char, etc.) and how they differ from non-primitive types.
Control Structures: Revise loops (for, while, do-while), conditional statements (if-else, switch-case), and how they control program flow.
Exception Handling: Know how try, catch, finally, and custom exceptions are used to manage errors in Java.
Collections Framework: Familiarize yourself with classes such as ArrayList, HashSet, HashMap, and their interfaces (List, Set, Map).
Interview Tip: Be prepared to discuss the time and space complexities of different collection types.
3. Java Memory Management
Understanding how Java manages memory can set you apart from other candidates:
Heap vs. Stack Memory: Explain the difference and how Java allocates memory.
Garbage Collection: Understand how it works and how to manage memory leaks.
Memory Leaks: Be prepared to discuss common scenarios where memory leaks may occur and how to avoid them.
Interview Tip: You may be asked how to optimize code for better memory management or to explain how Java’s finalize() method works.
4. Multithreading and Concurrency
With modern applications requiring multi-threading for efficient performance, expect questions on:
Threads and the Runnable Interface: Know how to create and run threads.
Thread Lifecycle: Be aware of thread states and what happens during transitions (e.g., from NEW to RUNNABLE).
Synchronization and Deadlocks: Understand how to use synchronized methods and blocks to manage concurrent access, and how deadlocks occur.
Concurrency Utilities: Review tools like ExecutorService, CountDownLatch, and Semaphore.
Interview Tip: Practice writing simple programs demonstrating thread synchronization and handling race conditions.
5. Java 8 Features and Beyond
Many companies expect candidates to be familiar with Java’s evolution, especially from Java 8 onward:
Lambda Expressions: Know how to write concise code with functional programming.
Streams API: Understand how to use streams for data manipulation and processing.
Optional Class: Learn to use Optional for handling null checks effectively.
Date and Time API: Review java.time package for managing date and time operations.
Interview Tip: Be prepared to solve coding problems using Java 8 features to show you’re up-to-date with recent enhancements.
6. Design Patterns
Java interviews often include questions on how to write clean, efficient, and scalable code:
Singleton Pattern: Know how to implement and when to use it.
Factory Pattern: Understand the basics of creating objects without specifying their exact class.
Observer Pattern: Be familiar with the publish-subscribe mechanism.
Decorator and Strategy Patterns: Understand their practical uses.
Interview Tip: Have examples ready that demonstrate how you’ve used these patterns in your projects.
7. Commonly Asked Coding Problems
Prepare by solving coding problems related to:
String Manipulations: Reverse a string, find duplicates, and check for anagrams.
Array Operations: Find the largest/smallest element, rotate arrays, or merge two sorted arrays.
Linked List Questions: Implement basic operations such as reversal, detecting cycles, and finding the middle element.
Sorting and Searching Algorithms: Review quicksort, mergesort, and binary search implementations.
Interview Tip: Practice on platforms like LeetCode or HackerRank to improve your problem-solving skills under time constraints.
Final Preparation Tips
Mock Interviews: Conduct practice interviews with peers or mentors.
Review Your Code: Ensure your past projects and code snippets are polished and ready to discuss.
Brush Up on Basics: Don’t forget to revise simple concepts, as interviews can include questions on any level of difficulty.
For more in-depth preparation, watch this helpful video that provides practical examples and coding tips to boost your confidence.
With these concepts in mind, you'll be well-equipped to handle any Java interview with poise. Good luck!
0 notes
Text
How to Sort a HashMap in Java Efficiently
Discover how to use Java's SortedMap and TreeMap to create a sorted HashMap. Learn about sorting mechanisms, benefits, and practical applications for managing key-value pairs efficiently.
0 notes