From 100398953a54bfabb3c83719d22a434702804683 Mon Sep 17 00:00:00 2001 From: Rhinemann Date: Mon, 8 May 2023 10:53:20 +0300 Subject: [PATCH] Slight rehash. --- Java/lab_3/lab_3.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Java/lab_3/lab_3.java b/Java/lab_3/lab_3.java index e048b29..394e4e5 100644 --- a/Java/lab_3/lab_3.java +++ b/Java/lab_3/lab_3.java @@ -19,7 +19,6 @@ public class lab_3 { result = string.substring(leftBoundary + 1, rightBoundary); maxStrLength = rightBoundary - leftBoundary - 1; } - return; } public static int longestPalSubstr(StringBuilder string) @@ -40,7 +39,7 @@ public class lab_3 { public static String compareStrings(StringBuilder builder) { for (int leftBoundary = 0; leftBoundary <= builder.length(); leftBoundary++) { - for (int rightBoundary = builder.length(); leftBoundary >= 0; rightBoundary--) { + for (int rightBoundary = builder.length(); rightBoundary >= leftBoundary; rightBoundary--) { if (result.equals(builder.substring(leftBoundary, rightBoundary).toLowerCase().replaceAll("[^a-z]",""))) { return builder.substring(leftBoundary, rightBoundary); } @@ -52,7 +51,7 @@ public class lab_3 { public static void main(String[] args) { StringBuilder stringToDetect = new StringBuilder("Eva, can I see bees in a cave?"); - System.out.println("Initial string: " + stringToDetect.toString()); + System.out.println("Initial string: " + stringToDetect); System.out.println("Length is: " + longestPalSubstr(stringToDetect)); } }