compile error 1.5 (string method)

Posted on 2008-11-11
Medium Priority
Last Modified: 2012-05-05
I have written following code to convert backslash to forwardslash.
if(filePathPrefix.indexOf("\\") > -1)
      filePathPrefix = filePathPrefix.replace("\\", "/");

This code works fine in 1.4 but gives a compile time error in 1.5
The type Comparable is not generic; it cannot be parameterized with arguments <String>
Please tell me how to resolve this
Question by:julie_456
  • 3
LVL 86

Accepted Solution

CEHJ earned 400 total points
ID: 22931363
To be more efficient all round, as well as to solve the problem, you can do
filePathPrefix = filePathPrefix.replace('\\', '/');

Open in new window

LVL 12

Expert Comment

ID: 22932993
I'm assuming you know that you can use File.separator to get the proper character for your plaform.  That said, you can always use a forward slash ("/") since it works on all platforms, including Windows.  To make sure you have all forward slashes, you can use:

path = replace(path,"\","/","all);path = replace(path,"\","/","all);
LVL 86

Expert Comment

ID: 22933189
>>This code works fine in 1.4 but gives a compile time error in 1.5

It's actually exactly the other way around. The version of replace you were using was introduced in 1.5
LVL 86

Expert Comment

ID: 22937818

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

864 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