Friday, November 10, 2023

Functional Interface

Generic Functional Interface:
package LambdaGenericsExample1;
@FunctionalInterface
public interface FunctionalGenerics {
	R execute(T t);
}
Here,
  R -> Return type
  T -> Takes a string as a parameter
  
It's having abstract method execute. It takes a String and returns a string.

Wednesday, August 23, 2023

python substring output "jkl-mno-test" from string "abc:def:ghi::jkl-mno-test"

python substring output "jkl-mno-test" from string "abc:def:ghi::jkl-mno-test" To extract the substring "jkl-mno-test" from the string "abc:def:ghi::jkl-mno-test" in Python, you can use slicing. Here's how you can do it:
original_string = "abc:def:ghi::jkl-mno-test"
substring = original_string.split("::")[-1]
print(substring)
In this code, split("::") breaks the original string into parts using "::" as the delimiter and returns a list of parts. Since you're interested in the last part, you can use [-1] to access the last element of the list, which will be "jkl-mno-test". The output will be:
jkl-mno-test