0% found this document useful (0 votes)
14 views1 page

Functii Java

The document contains code snippets for finding the maximum value in an array, extracting the first n characters of a string, extracting the last n characters of a string, checking if a character is a digit, checking if a string contains a dot, and finding the index of the last dot in a string.

Uploaded by

Diana Hartan
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
0% found this document useful (0 votes)
14 views1 page

Functii Java

The document contains code snippets for finding the maximum value in an array, extracting the first n characters of a string, extracting the last n characters of a string, checking if a character is a digit, checking if a string contains a dot, and finding the index of the last dot in a string.

Uploaded by

Diana Hartan
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 1

public static int maxArr(int[] arr) {

int maxValue = arr[0];


for (int i = 1; i < arr.length; i++) {
if (arr[i] > maxValue) {
maxValue = arr[i];
}
}
return maxValue;
}

--------------------------------------------------------------------
public static String extractFirstn (String str) {
String result = " ";
for(int i=0; i<=str.length(); i++) {
result = str.substring(0,str.length());
}
return result;
}
===============================================================================

public static String extractLastn(String str) {


String result = " ";
int len = str.length();
for (int i = len - 1; i >= 0; i--) {
result = result + str.charAt(i);
}
return result;

}
===================================================================================
=

public static boolean isdigit(char ch) {


boolean b = Character.isDigit(ch);
return b;
}

================================================================

public static boolean Containsdot(String str) {


boolean b = str.contains(".");
return b;
}

===============================================================

public static int lastIndex(String str) {

int result;

result = str.lastIndexOf('.');

return result;
}
=================================================================

You might also like