Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bamacharanchhandogi/java-easy-snippet
Boost your Java development productivity with the Java Boilerplate Generator extension for Visual Studio Code
https://github.com/bamacharanchhandogi/java-easy-snippet
codesnippets easy-to-use hacktoberfest java java-snippets json vscode-extension vscode-snippets
Last synced: about 2 months ago
JSON representation
Boost your Java development productivity with the Java Boilerplate Generator extension for Visual Studio Code
- Host: GitHub
- URL: https://github.com/bamacharanchhandogi/java-easy-snippet
- Owner: BamaCharanChhandogi
- License: mit
- Created: 2024-01-29T19:38:08.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-08-26T17:39:29.000Z (4 months ago)
- Last Synced: 2024-10-11T20:18:59.816Z (2 months ago)
- Topics: codesnippets, easy-to-use, hacktoberfest, java, java-snippets, json, vscode-extension, vscode-snippets
- Homepage: https://marketplace.visualstudio.com/items?itemName=BamaCharanChhandogi.JavaSnippet
- Size: 192 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Java Easy Snippet
## Description
Boost your Java development productivity with the **Java Boilerplate Generator** extension for Visual Studio Code. Say goodbye to repetitive code setup and hello to streamlined project initialization. This extension provides essential Java boilerplate code snippets and templates, helping you kickstart your projects swiftly and efficiently.
## Downloaded: 500+
## How to Use
**Step 1:** Install Java Easy Snippet
**Step 2:** Not Downloaded Yet? [Download Now](https://marketplace.visualstudio.com/items?itemName=BamaCharanChhandogi.JavaSnippet)
**Step 3:** Find all snippets below and use as per need.
**Step 4:** Happy Coding## Demo Screenshot
![hello](images/screen.png)
# All Java Snippet Shortcuts here
| No | Java Snippet Short Code | Description |
| :-- | :----------------------- | :----------------------------------|
| 1 | java | Basic Java Class with Main Method |
| 2 | jclass | Basic Java public Class code |
| 3 | jmain | Basic Java code with Main Method |
| --- |--------------------------|----------------------------------- |
| --- |--------------------------|----------------------------------- |
| 4 | jscan |Java class with a Scanner object for user input |
| 5 | jscanint | Scanner object for user input Integer |
| 6 | jscanstr | Scanner object for user input String |
| 7 | jscandouble | Scanner object for user input double |
| 8 | jscanlong | Scanner object for user input Long|
| 9 | jscanfloat | Scanner object for user input Float|
| 10 | jscanbool | Scanner object for user input Boolean|
| 11 | jscanbyte | Scanner object for user input Byte|
| 12 | jscanshort |Scanner object for user input short|
| 13 | jscanchr |Scanner object for user input Char |
| 14 | jscanbiginteger |Scanner object for user input Big Integer |
| 15 | jscanbigdecimal |Scanner object for user input Big Decimal |
| 16 | jscannextline |Scanner object for user input Next Line|
| 17 | jscanintarray | Scanner object for user input Integer Array|
| 18 | jscanstrarray | Scanner object for user input String Array |
| 19 | jscanintarraylist | Scanner object for user input Integer ArrayList |
| 20 | jscanstrarraylist |Scanner object for user input String ArrayList |
| 21 | jscanintlinkedlist | Scanner object for user input Integer LinedList|
| 22 | jscanstrlinkedlist | Scanner object for user input String LinkedList|
| 23 | jscanintqueue | Scanner object for user input Integer Queue|
| 24 | jscanstrqueue | Scanner object for user String Queue |
| 25 | jscanintstack | Scanner object for user input Integer stack |
| 26 | jscanstrstack | Scanner object for user String Integer Stack |
| 27 | jscanintset | Scanner object for user input Integer set|
| 28 | jscanstrset | Scanner object for user input String Set|
| 29 | jscaninttreemap |Scanner object for user input Integer TreeMap |
| 30 | jscanstrtreemap |Scanner object for user input String treeMap |
| 31 | jscanintpriorityqueue |Scanner object for user input Integer Priority Queue|
| 32 | jscanstrpriorityqueue |Scanner object for user String Integer Priority Queue|
| 33 | jscaninthashset |Scanner object for user input Integer Hash Set|
| 34 | jscanstrhashset |Scanner object for user input String Hash set|
| 35 | jscaninttreeset |Scanner object for user input Integer Tree Set|
| 36 | jscanstrtreeset |Scanner object for user input String Tree Set|
| 37 | jscanintlinkedhashset |Scanner object for user input Integer Linked Hash Set |
| 38 | jscanstrlinkedhashset |Scanner object for user input String Linked Hash set|
| --- |--------------------------|----------------------------------- |
| --- |--------------------------|----------------------------------- |
| 39 | jout | Creates a Java output code |
| 40 | joutarray | Creates a Java output code of Array|
| 41 | joutarraylist | Creates a Java output code of ArrayList|
| 42 | jouthashmap | Creates a Java output code HashMap |
| 43 | joutlinkedlist | Creates a Java output code LinkedList |
| 44 | joutqueue | Creates a Java output code Queue |
| 45 | joutstack | Creates a Java output code Stack |
| 46 | joutset | Creates a Java output code Set |
| 47 | jouttreemap | Creates a Java output code Tree Map|
| 48 | joutpq | Creates a Java output code Priority Queue|
| 49 | jouthashset | Creates a Java output code of Hash-Set |
| 50 | jouttreeset | Creates a Java output code of Tree-Set|
| 51 | joutlinkedhashset | Creates a Java output code of Linked Hash Set|
| --- |--------------------------|----------------------------------- |
| --- |--------------------------|----------------------------------- |
| 52 | jarraylist | Java Class with ArrayList |
| 53 | jarraylist | Java Class with ArrayList |
| 54 | jarraylist | Java Class with ArrayList |
| 55 | jhashmap | Java Class with HashMap |
| 56 | jlinkedlist | Java Class with LinkedList |
| 57 | jqueue | Java Class with Queue |
| 58 | jstack | Java Class with Stack |
| 59 | jset | Java Class with HashSet |
| 60 | jtreemap | Java Class with TreeMap |
| 61 | jpqueue | Java Class with PriorityQueue |
| 62 | jhashset | Java Class with HashSet |
| 63 | jtreeset | Java Class with TreeSet |
| 64 | jlinkedhashset | Java Class with LinkedHashSet |
| 65 | jarraylistiter | Java Class with ArrayList Iteration |
| 66 | jhashmapiter | Java Class with HashMap Iteration |
| 67 | jlinkedlistiter | Java Class with LinkedList Iteration|
| 68 | jqueueiter | Java Class with Queue Iteration |
| 69 | jstackiter | Java Class with Stack Iteration |
| 70 | jsetiter | Java Class with Set Iteration |
| 71 | jtreemapiter | Java Class with TreeMap Iteration |
| 72 | jpqueueiter | Java Class with PriorityQueue Iteration |
| --- |-------------------------|----------------------------------- |
| --- |-------------------------|----------------------------------- |
| 73 | userarray |user-defined Array |
| 74 | userarraylist | user-defined ArrayList |
| 75 | userlinkedlist | user-defined Singly LinkedList |
| 76 | userdoublylinkedlist | user-defined Doubly LinkedList |
| 77 | usercircularlinkedlist | user-defined Circular LinkedList |
| 78 | userstack |user-defined Stack |
| 79 | userqueue |user-defined Queue |
| 80 | userpriorityqueue |user-defined Priority Queue |
| 81 | userhashset |user-defined Hash Set |
| 82 | usertreeset | user-defined Tree Set |
| 83 | userlinkedhashset | User-defined Linked Hash Set |
| 84 | userhashmap | User-defined Hash Map |
| 85 | usertreemap | User-defined Tree Map |
| 86 | trywithresources | Try with resources |
| 87 | trycatch | Try catch exception |
| 88 | trycatchfinally | Try catch exception |
| 89 | ifelse | ifelse Condition |
| 90 | ifelseif | ifelseif Condition |
| 91 | switch | switch |
| 92 | for | for loop Iteration |
| 93 | foreach | foreach Iteration |
| 93 | while | while Iteration |
| 93 | dowhile | dowhile Iteration |
| 94 | jprintf | Creates a Java printf code |
# View Sample Snippet Codes of All Formats.
### ❇️ java = Basic Java Class with Main Method
```java
public class Main {
public static void main(String[] args) {
$0
}
}
```
### ❇️ jclass = Basic Java Public Class
```java
public class Main {
}
```
### ❇️ jmain = Basic Java Main Method
```java
public static void main(String[] args) {
$0
}
```
``` ```### ❇️ jscan = Java Class with Scanner
```java
Scanner sc = new Scanner(System.in);
```### ❇️ jscanint = Creates a Java class with a Scanner object for user input Integer
```java
int ${1:variable} = scanner.nextInt();
```### ❇️ jscanstr = Creates a Java class with a Scanner object for user input String
```java
String ${1:variable} = scanner.nextLine();
```### ❇️ jscandouble = Creates a Java class with a Scanner object for user input Double
```java
double ${1:variable} = scanner.nextDouble();
```
## ❇️ jscandfloat = Creates a Java class with a Scanner object for user input Float
```java
float ${1:variable} = scanner.nextFloat();
```
## ❇️ jscanlong = Creates a Java class with a Scanner object for user input Long
```java
float ${1:variable} = scanner.nextLong();
```
## ❇️ jscanbool = Creates a Java class with a Scanner object for user input Boolean
```java
boolean ${1:variable} = scanner.nextBoolean();
```## ❇️ jscannextline = Creates a Java class with a Scanner object for user input Line
```java
scanner.nextLine();
```
## ❇️ jscanintarray = Creates a Java class with a Scanner object for user input Integer Array.
```java
Scanner sc = new Scanner(System.in);
int[] arr = new int[sc.nextInt()];for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
```
### ❇️ jscanstrarray = Creates a Java class with a Scanner object for user input String Array
```java
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine(); // Consume the newline characterString[] arr = new String[n];
for (int i = 0; i list = new ArrayList<>();
for (int i = 0; i < n; i++) {
list.add(scanner.nextInt());
}
```
### ❇️ jscanstrarraylist = Creates a Java class with a Scan scanner object for user input String Array list
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine(); // Consume the newline characterArrayList list = new ArrayList<>();
for (int i = 0; i < n; i++) {
list.add(scanner.nextLine());
}
```
### ❇️ jscanintlinkedlist = Creates a Java class with a Scan scanner object for user input Integer LinkedList
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();List list = new LinkedList<>();
for (int i = 0; i < n; i++) {
list.add(scanner.nextInt());
}
```
### ❇️ jscanstrlinkedlist = Creates a Java class with a Scan scanner object for user input String LinkedList
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine(); // Consume the newline characterLinkedList list = new LinkedList<>();
for (int i = 0; i < n; i++) {
list.add(scanner.nextLine());
}
```
### ❇️ jscanintqueue = Creates a Java class with a Scan scanner object for user input Integer Queue
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();Queue queue = new LinkedList<>();
for (int i = 0; i < n; i++) {
queue.offer(scanner.nextInt());
}
```
### ❇️ jscanstrqueue = Creates a Java class with a Scan scanner object for user input String Queue
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine(); // Consume the newline characterQueue queue = new LinkedList<>();
for (int i = 0; i < n; i++) {
queue.offer(scanner.nextLine());
}
```
### ❇️ jscanintstack = Creates a Java class with a Scan scanner object for user input Integer Stack
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();Stack stack = new Stack<>();
for (int i = 0; i < n; i++) {
stack.push(scanner.nextInt());
}
```
### ❇️ jscanstrstack = Creates a Java class with a Scan scanner object for user input String Stack
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine(); // Consume the newline characterStack stack = new Stack<>();
for (int i = 0; i < n; i++) {
stack.push(scanner.nextLine());
}
```
### ❇️ jscanintset = Creates a Java class with a Scan scanner object for user input Integer Set
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();Set set = new HashSet<>();,
for (int i = 0; i < n; i++) {
set.add(scanner.nextInt());
}
```
### ❇️ jscanstrset = Creates a Java class with a Scan scanner object for user input String Set
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine(); // Consume the newline characterSet set = new HashSet<>();,
for (int i = 0; i < n; i++) {
set.add(scanner.nextLine());
}
```### ❇️ jscaninttreemap = Creates a Java class with a Scan scanner object for user input Integer TreeMap
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();Map map = new TreeMap<>();
for (int i = 0; i < n; i++) {
set.add(scanner.nextInt());
}
```
### ❇️ jscansrset = Creates a Java class with a Scan scanner object for user input String TreeMap
```java
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine(); // Consume the newline characterMap map = new TreeMap<>();
for (int i = 0; i < n; i++) {
map.put(scanner.nextLine(), scanner.nextInt());
}
```
``` ```### ❇️ jout = Creates a Java output code
```java
System.out.println();
```
### ❇️ jprintf = Creates a Java printf code
```java
System.out.printf();
```
### ❇️ joutarray = Creates a Java output code of Array
```java
for (final var element : arr) {
System.out.println(element);
}
```
### ❇️ joutarraylist = Creates a Java output code of ArrayList
```java
for (final var element : list) {
System.out.println(element);
}
```
### ❇️ jouthashmap = Creates a Java output code of Hash Map
```java
for (final var entry : map.entrySet()) {
System.out.println(entry.getKey() + entry.getValue());
}
```
### ❇️ joutlinkedlist = Creates a Java output code of LinkedList
```java
for (final var element : list) {
System.out.println(element);
}
```
``` ```### ❇️ jarraylist = Java Class with ArrayList
```java
List list = new ArrayList<>();
```
### ❇️ jhashmap = Java Class with HashMap
```java
Map map = new HashMap<>();
```
### ❇️ jlinkedlist = Java Class with LinkedList
```java
List list = new LinkedList<>();
```
### ❇️ jqueue = Java Class with Queue
```java
Queue queue = new LinkedList<>();
```
### ❇️ jstack = Java Class with Stack
```java
Stack stack = new Stack<>();
```
### ❇️ jset = Java Class with HashSet
```java
HashSet set = new HashSet<>();
```
``` ```
### ❇️ userlinkedlist = User Defined Linked List code.
```java
static class LinkedList {
private Node head;
private int size;private static class Node {
T data;
Node next;Node(T data) {
this.data = data;
this.next = null;
}
}public LinkedList() {
head = null;
size = 0;
}public void add(T element) {
Node newNode = new Node<>(element);
if (head == null) {
head = newNode;
} else {
Node current = head;
while (current.next != null) {
current = current.next;
}
current.next = newNode;
}
size++;
}public void print() {
Node current = head;
while (current != null) {
System.out.print(current.data + " ");
current = current.next;
}
System.out.println();
}public int size() {
return size;
}
}
```
### ❇️ userhashset = User defined hash Set
```java
static class HashSet {
private HashMap map;public HashSet() {
map = new HashMap<>();
}public void add(T element) {
map.put(element, true);
}public boolean contains(T element) {
return map.containsKey(element);
}public void remove(T element) {
map.remove(element);
}public boolean isEmpty() {
return map.isEmpty();
}public int size() {
return map.size();
}
}
```
### ❇️ userstack = User Defined Stack
```java
static class Stack {
private Node top;
private int size;private static class Node {
T data;
Node next;Node(T data) {
this.data = data;
this.next = null;
}
}public Stack() {
top = null;
size = 0;
}public void push(T element) {
Node newNode = new Node<>(element);
newNode.next = top;
top = newNode;
size++;
}public T pop() {
if (top == null) {
throw new EmptyStackException();
}
T data = top.data;
top = top.next;
size--;
return data;
}public T peek() {
if (top == null) {
throw new EmptyStackException();
}
return top.data;
}public boolean isEmpty() {
return top == null;
}public int size() {
return size;
}
}
```
### ❇️ trywithresources = Java try-with-resources block
```java
try (Scanner scanner = new Scanner(System.in)) {
$0
} catch (Exception e) {
System.out.println(e.getMessage());
}
```
### ❇️ trycatch = Java try-catch block
```java
try {
$0
} catch (Exception e) {
System.out.println(e.getMessage());
}
```
### ❇️ trycatchfinally = Java try-catch-finally block
```java
try {
$0
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
System.out.println("Finally block");
}
```
### ❇️ ifelse = Java if-else statement
```java
if ($1) {
$0
} else {
}
```
### ❇️ ifelseif = Java if-else-if statement
```java
if ($1) {
$0
} else if ($2) {
} else {
}
```
### ❇️ switch = Java switch statement
```java
switch ($1) {
case $2:
$0
break;
default:
break;
}
```
### ❇️ for = Java for loop
```java
for (int i = 0; i < $1; i++) {
$0
}
```
### ❇️ foreach = Java for-each loop
```java
for ($1 : $2) {
$0
}
```
### ❇️ while = Java while loop
```java
while ($1) {
$0
}
```
### ❇️ dowhile = Java do-while loop
```java
do {
$0
} while ($1);
```