Search:

Type: Posts; User: javabro

Search: Search took 0.36 seconds.

  1. [SOLVED] Re: Compare the last 4 strings in String s1 and String s2

    Do you mean something like this?


    if(s1.substring(p1).equals(s2.substring(p2))){
    return true;
    }


    Originally, I want to do something like...
  2. [SOLVED] Re: Compare the last 4 strings in String s1 and String s2

    The first for loop is to get the total length of s1 and the second for loop is to get the total length of s2. I'm doing these to get the last index of the strings.

    I realised I can actually do...
  3. [SOLVED] Re: Compare the last 4 strings in String s1 and String s2

    If you're referring to compare two strings with the same last 4 letters, then yes, equals method does work.



    public class compareLast4
    {
    public static void main(String[] args){
    ...
  4. [SOLVED] Re: Compare the last 4 strings in String s1 and String s2

    I've tried the equals method and it doesn't work.

    The one I've created works because I'm comparing numbers using the .length().
  5. [SOLVED] Compare the last 4 strings in String s1 and String s2

    Hi!

    I'm quite new to Java and I've got this question that requires me to solve a basic algorithm.

    "Implement a method public static boolean compareLast4(String s1, String s2) that returns true...
Results 1 to 5 of 5