Movatterモバイル変換


[0]ホーム

URL:


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 two new blogposts#3

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gauravkukade merged 1 commit intomasterfromblog/create-uuid-in-java
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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
81 changes: 81 additions & 0 deletions_posts/2020-12-23-create-uuid-in-java.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
---
layout: post
title: "How To Create UUID in Java?"
author: gaurav
image: assets/images/2020-12-23/create-uuid-in-java.png
categories: [ Java, Core Java, String]
description: In this article you will see, how to create UUID in Java.

---

## Introduction

UUID, a universally unique identifier is a 128-bit number used to identify information in computer systems.

UUID is made of hex digits along with 4 hyphen ("-") symbols. The length of a UUID is 36 characters.

There are 5 types of UUID but mostly version 4 i.e. Randomly Generated UUID is used.

We are going to create the version 4 UUID here.

### Example UUID

df6fdea1-10c3-474c-ae62-e63def80de0b

## How to create UUID in Java?

Creating a Randomly Generated UUID (version 4) is really easy in Java.

UUID Class is present in `java.util` package. And it has the static method `randomUUID()` which returns the randomly generated UUID.

The example is given below.

```java
import java.util.UUID;

/**
* A Java program to create a Randomly Generated UUID i.e. Version 4 UUID
* @author Gaurav Kukade at coderolls.com
*
*/
public class CreateUUID {

public static void main(String[] args) {

// creating random uuid i.e. version 4 UUID
UUID uuid = UUID.randomUUID();

System.out.println("Printing the randomly generated UUID value......\n");

System.out.println("uuid: "+uuid);

}

}

```
Output
```java
Printing the randomly generated UUID value......

uuid: e3aed661-ccc2-42fd-ad69-734fee350cd2

```

Get the [above code as GitHub Gist](https://gist.github.com/gauravkukade/395f314c549969bd300d72c7e032dbcb).

--------

You can visit my [YouTube channel 'coderolls'](https://www.youtube.com/channel/UCl31HHUdQbSHOQfc9L-wo3w?view_as=subscriber?sub_confirmation=1) to find more video tutorials.

If you found this article worth, support me by [giving a cup of Coffee ☕](https://www.paypal.me/GauravKukade)

#### Related Articles

- [Learn About Java String Pool And intern() Method](https://coderolls.com/java-string-pool-and-intern-method/)
- [How Do I Compare Strings In Java](https://coderolls.com/compare-strings-in-java/)
- [How To Reverse A String In Java (5 ways)](https://coderolls.com/reverse-a-string-in-java/)
- [Compare Two Strings Lexicographically In Java](https://coderolls.com/compare-two-strings-lexicographically-in-java/)
- [Difference Between StringBuffer and StringBuilder class](https://coderolls.com/difference-between-stringbuffer-and-stringbuilder/)

- [8 Basic GIT Commands Every Newbie Developer Must Know](https://coderolls.com/basic-git-commands/)
65 changes: 65 additions & 0 deletions_posts/2020-12-25-convert-stringbuilder-to-string-in-java.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
---
layout: post
title: "How To Convert StringBuilder To String In Java?"
author: gaurav
image: assets/images/2020-12-25/convert-stringbuilder-to-string-in-java.png
categories: [ Java, Core Java, String]
description: In this article you will see, how to convert a StringBuilder to String in Java.
featured: false
---

## Introduction

Java `StringBuilder` is non-synchronized update of the `StringBuffer` class.

Sometimes there is need to convert the `StringBuilder` object to the `String`. We can do it easily by smply invoking the `toString()` method.

Let see the example program below.

## Java Program to convert `StringBuilder` to `String`

```java
/**
* A Java program to convert StringBuilder to String
* @author Gaurav Kukade at cderlls.com
*
*/
public class StringBuilderToString {

public static void main(String[] args) {
StringBuilder stringBuilder = new StringBuilder("Hello ");

stringBuilder.append("Gaurav ")
.append("Kukade!");

System.out.println("Printing strinBuilder as String: \n");
System.out.println(stringBuilder.toString());

}

}
```
Output:
```java
Printing strinBuilder as String:

Hello Gaurav Kukade!

```
Get the [above code as GitHub Gist](https://gist.github.com/gauravkukade/00bd416bcb2ca1c72dbcd600d48e2f78).

---------

You can visit my [YouTube channel 'coderolls'](https://www.youtube.com/channel/UCl31HHUdQbSHOQfc9L-wo3w?view_as=subscriber?sub_confirmation=1) to find more video tutorials.

If you found this article worth, support me by [giving a cup of Coffee ☕](https://www.paypal.me/GauravKukade)

#### Related Articles

- [Learn About Java String Pool And intern() Method](https://coderolls.com/java-string-pool-and-intern-method/)
- [How Do I Compare Strings In Java](https://coderolls.com/compare-strings-in-java/)
- [How To Reverse A String In Java (5 ways)](https://coderolls.com/reverse-a-string-in-java/)
- [Compare Two Strings Lexicographically In Java](https://coderolls.com/compare-two-strings-lexicographically-in-java/)
- [Difference Between StringBuffer and StringBuilder class](https://coderolls.com/difference-between-stringbuffer-and-stringbuilder/)

- [8 Basic GIT Commands Every Newbie Developer Must Know](https://coder
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

[8]ページ先頭

©2009-2025 Movatter.jp