Solved

left Function in java

Posted on 2003-12-04
5
7,778 Views
Last Modified: 2010-05-18
In VB this is a function, Left(string, length)  : Returns a Variant (String) containing a specified number of characters from the left side of a string.

is there anything like this in java? thanks
0
Comment
Question by:ocsurf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 125 total points
ID: 9878455
substring(0, length)
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9878469
System.out.println("Hello".substring(0, 3));

would output

Hel
0
 
LVL 1

Author Comment

by:ocsurf
ID: 9878485
Cool thanks...Can this be applied to int numbers too?
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9878501
You'd need to convert the int to a String first:

int myInt = 12345;
Integer.toString(myInt).substring(0, 3);

would give you:

123
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9878531
;-)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

696 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