This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package forEach; | |
public class AverAge { | |
public static void main(String[] args) { | |
int[] data = {1,2,3,4}; | |
System.out.println(average(data)); | |
int[] data2 = null; | |
System.out.println(average(data2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ppackage forEach; | |
public class ForEach { | |
public static void main(String[] args) { | |
int[] data1 = {1,2,3,4}; | |
System.out.println(oddElementSum(data1)); | |
int[] data2 = null; | |
System.out.println(oddElementSum(data2)); | |
System.out.println(oddElementSum(new int[]{0})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package array; | |
import java.util.Arrays; | |
public class PrintArray { | |
public static void main(String[] args) { | |
int[] data1 ={1, 5, 10 , 4}; | |
printArray(data1); | |
int[] data2 ={}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package array; | |
import java.util.Arrays; | |
public class Swap { | |
public static void main(String[] args) { | |
int[] data1 = {1,2,3,4,5}; | |
int i1 = 4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package array; | |
public class LastElementOfArray { | |
public static void main(String[] args) { | |
// int[] data ={1, 5, 10 , 4}; | |
// System.out.println(getLast(data)); | |
// int[] data ={}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tanks; | |
import java.awt.Color; | |
import java.awt.Dimension; | |
import java.awt.Graphics; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.WindowConstants; | |
public class BattleFieldMoveToQuadrant extends JPanel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tanks; | |
import java.awt.Color; | |
import java.awt.Dimension; | |
import java.awt.Graphics; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.WindowConstants; | |
public class BattleFieldTemplate extends JPanel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package logic; | |
public class EndlessCycle { | |
public static void main(String[] args) { | |
printNumbers(-44,9); | |
} | |
static void printNumbers(int i, int n){ | |
while (i<n){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package methods; | |
public class CountDown { | |
public static void main(String[] args) { | |
start(-4); | |
} | |
private static void start(int number){ | |
if(number>=0){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package task1; | |
import java.util.Scanner; | |
public class New { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
String s1 = scanner.nextLine(); |