Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Add link for reverse string and string to int videos in respective blogs #15

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
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions _posts/java-string/2019-12-02-reverse-a-string-in-java.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ Output:
```java
The reversed string of the 'coderolls.com' is: moc.slloredoc
```

#### Note:
In the `for` loop, I have assigned `blogName.length()-1` to i instead of `blogName.length()` because the characters in the string are indexed from 0.

I have given an image below to show the string indexing.

![Showing indexes of the characters in the string.](/assets/images/2019-12-02/string-indexing.png)

Also you can watch [the video on my youtube channel for reverse a string with the above method](https://www.youtube.com/watch?v=vrTYrQuB0BE).

[![How To Reverse A String In Java](https://img.youtube.com/vi/vrTYrQuB0BE/0.jpg)](https://www.youtube.com/watch?v=vrTYrQuB0BE "How To Reverse A String In Java")

## 2. Using `getBytes()` method of String
In the `getBytes()` method of Java String first encodes the specified string into the sequence of bytes using the platforms default charset and then save the result in the byte array. The same byte array will be returned.
```java
Expand Down
6 changes: 5 additions & 1 deletion _posts/java-string/2020-01-05-convert-string-to-int.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ I have listed down two ways to convert a String into an Integer.
1. Using the `Integre.parseInt()` method
2. Using the `Integer.valueOf()` method

You can watch [the video on my youtube channel for "How To Convert A String To An Integer In Java"](https://www.youtube.com/watch?v=pNHjvpNHVCs).

[![How To Convert A String To An Integer In Java](https://img.youtube.com/vi/pNHjvpNHVCs/0.jpg)](https://www.youtube.com/watch?v=pNHjvpNHVCs "How To Convert A String To An Integer In Java")

Now we will see the above ways to convert string to integer one by one.

## Using the `Integre.parseInt()` method
Expand Down Expand Up @@ -85,7 +89,7 @@ Output
134
```

## Let us know about `NumberFormatException`
## A Note about `NumberFormatException`

When you are trying to convert a string to integer but your string contains a value other than the decimal digits, then bothe the methods (`Integre.parseInt()` method and `Integer.valueOf()` method) will throw the `NumberFormatException`.

Expand Down