get_post_meta()
update_post_meta()
static String daytime(int hour){
if (hour >24 || hour < 0)
throw new IllegalArgumentException("Bad argument");
if(hour > 21 || hour < 6)
return "Good night";
else if(hour >= 15)
return "Good evening";
else if(hour >= 11)
return "Good after noon";
else
return "Good morning";
}
@FunctionalInterface
interface BiIntFunction {
void apply(x: int, y: int);
}
и применять примерно так:
void doSomething(int borderX, int borderY, body: BiIntFunction) {
for (int x = 0; x < borderX; x++) {
for (int y = 0; y < borderY; y++) {
body.apply(x, y);
}
}
}
//....
doSomething(sizeX, sizeY, (x, y) -> { ... your code here ... });
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Введите количество строк: ");
var n = Integer.valueOf(in.nextLine());
for (int i = 0; i < n; i++) {
System.out.println("Введите строку: ");
var s = in.nextLine();
var parts = s.split(" ");
var first = parts[i];
parts[i] = parts[parts.length - 1];
parts[parts.length - 1] = first;
var result = String.join(" ", parts);
System.out.println(result);
}
}