Created
September 29, 2023 07:09
-
-
Save heerdyes/9204da5f0fbc707b2f001dfa743e5c70 to your computer and use it in GitHub Desktop.
java_snippets
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
import java.io.Console; | |
public class arrays00 { | |
public static void main(String[] args) { | |
int[] a = new int[] { 11, 55, 73, 29 }; | |
int i = 0; | |
while(i < a.length) { | |
System.out.println(a[i]); | |
i++; | |
} | |
} | |
} |
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
import java.io.Console; | |
public class pattern00 { | |
public static void main(String[] args) { | |
Console c = System.console(); | |
String ln = c.readLine(); | |
int n = Integer.parseInt(ln); | |
// loop n times | |
int i = 1; | |
while(i <= n) { | |
System.out.print("/\\"); | |
i++; | |
} | |
System.out.println(); | |
} | |
} |
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
import java.io.Console; | |
public class pattern01 { | |
public static void main(String[] args) { | |
Console c = System.console(); | |
String ln = c.readLine("enter n: "); | |
int n = Integer.parseInt(ln); | |
// loop n times | |
int i = 1; | |
while(i <= n) { | |
System.out.print("\"(\")"); | |
i++; | |
} | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment