compile error 1.5 (string method)

Posted on 2008-11-11
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
    LVL 86

    Accepted Solution

    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

    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

    >>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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Java MSI Solution 3 51
    Need some clarity on Rest API 5 51
    bigHeights  challenge 13 43
    ArrayLists in ArrayLists/HashMaps? 4 26
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    779 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

    18 Experts available now in Live!

    Get 1:1 Help Now