This file contains 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.util.Scanner; | |
public class GreatestCommonDivisorMethod { | |
/** Main method */ | |
public static void main(String[] args) { | |
// Create a Scanner | |
Scanner input = new Scanner(System.in); | |
// Prompt the user to enter two integers | |
System.out.print("Enter first integer: "); |
This file contains 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
public class AnalyzeNumbers { | |
public static void main(String[] args) { | |
java.util.Scanner input = new java.util.Scanner(System.in); | |
System.out.print("Enter the number of items: "); | |
int n = input.nextInt(); | |
double[] numbers = new double[n]; | |
double sum = 0; | |
System.out.print("Enter the numbers: "); | |
for (int i = 0; i < n; i++) { |
This file contains 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
public class CircleWithPrivateDataFields { | |
/** The radius of the circle */ | |
private double radius = 1; | |
/** The number of the objects created */ | |
private static int numberOfObjects = 0; | |
/** Construct a circle with radius 1 */ | |
public CircleWithPrivateDataFields() { | |
numberOfObjects++; |
This file contains 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
public class Bubble { | |
int x, y; | |
float r; | |
int incrX = (int) random(4,8); | |
int incrY = (int) random(2,8); | |
int red, green, blue, alpha; | |
public Bubble() { | |
x = (int)random(width); |
This file contains 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
public class Circle extends Shape { | |
private float r; // r is the radius of the circle | |
public Circle(float a, float b, float c) { | |
super(); // this is effectively like new Shape() | |
x = a; | |
y = b; | |
r = c; | |
// accept Shape's default of filled=false |
This file contains 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.File; | |
import java.io.FileNotFoundException; | |
import java.io.PrintWriter; | |
import java.util.Scanner; | |
public class FIleOutputYahooStockReport { | |
public static void main(String[] args) { | |
System.out.println("Starting ..."); |
This file contains 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
capture json from curl or postman, like | |
{ | |
"base": "USD", | |
"date": "2017-10-10", | |
"rates": { | |
"CAD": 1.2499, | |
... | |
... | |
} | |
} |
This file contains 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 edu.ggc.lutz.pixabayretrofit; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.URL; | |
import java.util.HashMap; | |
import java.util.List; |
This file contains 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.util.Scanner; | |
public class ComputeFactorial { | |
/** Main method */ | |
public static void main(String[] args) { | |
// Create a Scanner | |
Scanner input = new Scanner(System.in); | |
System.out.print("Enter a non-negative integer: "); | |
int n = input.nextInt(); | |
This file contains 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
public class AnyWildCardDemo { | |
public static void main(String[] args ) { | |
GenericStack<Integer> intStack = new GenericStack<Integer>(); | |
intStack.push(1); // 1 is autoboxed into new Integer(1) | |
intStack.push(2); | |
intStack.push(-2); | |
print(intStack); | |
} |