Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

left Function in java

Posted on 2003-12-04
5
Medium Priority
?
7,786 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

636 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