Solved

left Function in java

Posted on 2003-12-04
5
7,766 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 45
object oriented programming comparison 5 52
table example 4 19
javap not working 8 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
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.

932 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

12 Experts available now in Live!

Get 1:1 Help Now