Solved

end of string?

Posted on 2000-05-09
2
170 Views
Last Modified: 2010-04-01

How can we know end of string in Java?
In c or c++ every string is terminated by null character.

0
Comment
Question by:Veena85
  • 2
2 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 25 total points
Comment Utility
In Java every String has a length. Compare to that.

Example:

String str="abc";
char arr[]=new char[3];
for(i=0; i<str.length(); ++i)
{   arr[i]=str.charAt(i);
}
0
 
LVL 16

Expert Comment

by:imladris
Comment Utility
Note: length is a method of the String class. Many other methods are available for strings. See documentation for the String class.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now