Spaceship Operation in for Lexicographic Comparison
[1] By Java convention curly brackets belong in the same line as the preceding statement/expression.

Instead of this:

if
()
{}
else
{}

for
()
{}


do this:

if () {
    ...
} else {
    ...
}

for () {
    ...
}


I suggest you read the Google Java style guide for more tips: https://google.github.io/styleguide/javaguide.html

[2] You don't have to introduce an intermediate variable for holding chars, you can directly assign the result of charAt() method to an int variable: intChar1 = (int) str1.charAt(i);

[3] You don't have to do all those substring operations to make the strings the same length. Rewrite the main for loop to do as many iterations as there are characters in the shorter string. Written more succinctly: min(length(A), length(B) iterations

[4] To lexicographically compare two strings, you have to find the first different character in both strings and handle the remaining edge cases after the main for loop. Some pseudocode:

for i = 0; i &lt; (min(length(A), length(B)); i++
    if A[i] != B[i]
        if A[i] &lt; B[i] return -1
        else return 1

// If you didn't return from the method at this point, there are only three options left
String A is shorter than string B - return -1
String B is shorter than string A - return 1
String A and string B are equal - return 0