Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add JavaScript snippets #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Mathys-Gasnier merged 8 commits into quicksnip-dev:main from Axorax:main
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/data/_index.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@
{
"lang": "Rust",
"icon": "/icons/rust.svg"
},
{
"lang": "Java",
"icon": "/icons/java.svg"
}
]
129 changes: 129 additions & 0 deletions public/data/java.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
[
{
"categoryName": "Basics",
"snippets": [
{
"title": "Hello, World!",
"description": "Prints Hello, World! to the terminal.",
"code": [
"public class HelloWorld {",
" public static void main(String[] args) {",
" // Output: \"Hello, World!\"",
" System.out.println(\"Hello, World!\");",
" }",
"}"
],
"tags": ["java", "hello-world"],
"author": "axorax"
}
]
},
{
"categoryName": "String Manipulation",
"snippets": [
{
"title": "Reverse String",
"description": "Reverses the characters in a string.",
"code": [
"public class StringManipulation {",
" public static String reverseString(String s) {",
" StringBuilder reversed = new StringBuilder(s);",
" return reversed.reverse().toString();",
" }",
"",
" // Usage:",
" public static void main(String[] args) {",
" System.out.println(reverseString('hello')); // Output: 'olleh'",
" }",
"}"
],
"tags": ["java", "string", "reverse", "utility"],
"author": "axorax"
},
{
"title": "Check Palindrome",
"description": "Checks if a string is a palindrome.",
"code": [
"public class StringManipulation {",
" public static boolean isPalindrome(String s) {",
" String cleanString = s.replaceAll(\"\\s+\", \"\").toLowerCase();",
" StringBuilder reversed = new StringBuilder(cleanString);",
" return cleanString.equals(reversed.reverse().toString());",
" }",
"",
" // Usage:",
" public static void main(String[] args) {",
" System.out.println(isPalindrome('A man a plan a canal Panama')); // Output: true",
" }",
"}"
],
"tags": ["java", "string", "palindrome", "check"],
"author": "axorax"
},
{
"title": "Count Vowels",
"description": "Counts the number of vowels in a string.",
"code": [
"public class StringManipulation {",
" public static int countVowels(String s) {",
" int count = 0;",
" String vowels = 'aeiouAEIOU';",
" for (int i = 0; i < s.length(); i++) {",
" if (vowels.indexOf(s.charAt(i)) != -1) {",
" count++;",
" }",
" }",
" return count;",
" }",
"",
" // Usage:",
" public static void main(String[] args) {",
" System.out.println(countVowels('hello')); // Output: 2",
" }",
"}"
],
"tags": ["java", "string", "vowels", "count"],
"author": "axorax"
},
{
"title": "Find Substring First Occurrence",
"description": "Finds the first occurrence of a substring in a string.",
"code": [
"public class StringManipulation {",
" public static int findSubstring(String s, String substring) {",
" return s.indexOf(substring);",
" }",
"",
" // Usage:",
" public static void main(String[] args) {",
" System.out.println(findSubstring('hello world', 'world')); // Output: 6",
" }",
"}"
],
"tags": ["java", "string", "substring", "search"],
"author": "axorax"
},
{
"title": "Capitalize First Letter",
"description": "Capitalizes the first letter of a string.",
"code": [
"public class StringManipulation {",
" public static String capitalizeFirstLetter(String s) {",
" if (s == null || s.isEmpty()) {",
" return s;",
" }",
" return s.substring(0, 1).toUpperCase() + s.substring(1);",
" }",
"",
" // Usage:",
" public static void main(String[] args) {",
" System.out.println(capitalizeFirstLetter('hello')); // Output: 'Hello'",
" }",
"}"
],
"tags": ["java", "string", "capitalize", "utility"],
"author": "axorax"
}
]
}
]
Loading

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /