java classes and methods simple logic with comments
Java
import java.lang.Math;
import java.util.Scanner;
public class NumberShapes {
public static void main(String[] args) {
class Number {
int number;
public boolean isTriangular() {
int x = 1;
int triangularNumber = 1;
while (triangularNumber < number) { // while number is greater than the triangularNumber keep going.
// number >
// trianguarNumber
x++;
triangularNumber = triangularNumber + x; // triangularNumber += x;
// this helps during testing to see how the counter works as we increment
System.out.println(triangularNumber);
}
// after the while loop runs we check what we have left and compare
if (triangularNumber == number) {
return true;
} else {
return false;
}
} // end - isTriangular()
} // end - Number class
Number myNumber = new Number();
myNumber.number = 21;
System.out.println(myNumber.isTriangular());
}
}
Also in Java:
- Title
- how to create java jframe in eclipse
- Category
- Java
- Title
- java string to char array
- Category
- Java
- Title
- get material of block bukkit
- Category
- Java
- Title
- how to convert string to array in java
- Category
- Java
- Title
- java if different ways
- Category
- Java
- Title
- java string contains char
- Category
- Java
- Title
- Java nested array hashcode
- Category
- Java
- Title
- java create clas
- Category
- Java
- Title
- How do you count characters in a string array in Java?
- Category
- Java
- Title
- sum of arraylist java 8
- Category
- Java
- Title
- FORM EN JAVA SCRIPT
- Category
- Java
- Title
- libgdx move camera with touch
- Category
- Java
- Title
- java null pointer exception
- Category
- Java
- Title
- java flood fill
- Category
- Java
- Title
- spigot custom mob
- Category
- Java
- Title
- java queue
- Category
- Java
- Title
- testing the web layer without authentication spring
- Category
- Java
- Title
- how to check if in array java
- Category
- Java
- Title
- write an infinite loop java
- Category
- Java
- Title
- java arraylist
- Category
- Java
- Title
- 3-way radix quicksort java
- Category
- Java
- Title
- how do you concatenate an int with a string in java
- Category
- Java
- Title
- java manacher's algorithm
- Category
- Java
- Title
- how to get binary value in java
- Category
- Java
- Title
- java 8 stream group by example
- Category
- Java
- Title
- localdate to string java
- Category
- Java
- Title
- restart application programmatically android
- Category
- Java
- Title
- java how to stop code
- Category
- Java
- Title
- separateur JMenu swing java
- Category
- Java
- Title
- convert from integer to character java
- Category
- Java
- Title
- java import
- Category
- Java
- Title
- binary search java
- Category
- Java
- Title
- compile java
- Category
- Java
- Title
- objectoutputstream exemple
- Category
- Java
- Title
- java do while
- Category
- Java
- Title
- java console write
- Category
- Java
- Title
- java switch case
- Category
- Java
- Title
- java create a set with values
- Category
- Java
- Title
- android notification addaction example
- Category
- Java
- Title
- how to use the this keyword in java
- Category
- Java
- Title
- vector in java
- Category
- Java
- Title
- android dynamically create layer-list with item and shape site:stackoverflow.com
- Category
- Java
- Title
- android switch on change
- Category
- Java
- Title
- arraylist to int array java
- Category
- Java
- Title
- Java int to roman
- Category
- Java
- Title
- java read from file
- Category
- Java
- Title
- bracket balancing program in java
- Category
- Java
- Title
- spigot deal damage
- Category
- Java
- Title
- java how to iterate through a arraylist
- Category
- Java
- Title
- eliminar fila jtable java
- Category
- Java
- Title
- get host from request object java
- Category
- Java
- Title
- spigot chat color with symbol
- Category
- Java
- Title
- java 8 hashmap example stackoverflow
- Category
- Java
- Title
- iterate map in java
- Category
- Java
- Title
- how to create a subclass in java
- Category
- Java
- Title
- imagesbutton how to set background
- Category
- Java
- Title
- set preference value android
- Category
- Java
- Title
- nikita kaksharov
- Category
- Java
- Title
- jtable fill panel
- Category
- Java
- Title
- java spring boot json deserialize date inaccurate
- Category
- Java
- Title
- foreach not applicable to type - binary tree sort
- Category
- Java
- Title
- cordova cannot find symbol import com.google.firebase.iid.FirebaseMessagingService;
- Category
- Java
- Title
- java jpa criteriabuilder in xample
- Category
- Java
- Title
- casting java
- Category
- Java
- Title
- java file path linux
- Category
- Java
- Title
- pascals triangle java
- Category
- Java
- Title
- boolean checkbox swing
- Category
- Java
- Title
- how to extract data from delimited text file in java
- Category
- Java
- Title
- java mouseevent
- Category
- Java
- Title
- hello world java
- Category
- Java
- Title
- how to add element to arraylist
- Category
- Java
- Title
- java sql question mark
- Category
- Java
- Title
- using class in java
- Category
- Java
- Title
- priority queue in java
- Category
- Java
- Title
- how to copy list item to another list in java
- Category
- Java
- Title
- java convert edittext to double
- Category
- Java
- Title
- nullpointer extension
- Category
- Java
- Title
- selection sort in java
- Category
- Java
- Title
- java 11 initialize map
- Category
- Java
- Title
- convert int to string java
- Category
- Java
- Title
- how to count the number of occurrences of an element in a arraylist in java
- Category
- Java
- Title
- java get current date without time
- Category
- Java
- Title
- java 8 printstacktrace in system.out
- Category
- Java
- Title
- java script zip function
- Category
- Java
- Title
- list in java
- Category
- Java
- Title
- create instance object java
- Category
- Java
- Title
- counting the sequence of character in string java
- Category
- Java
- Title
- same method name with different arguments
- Category
- Java
- Title
- integer max value java
- Category
- Java
- Title
- insert element into arraylist java
- Category
- Java
- Title
- getordefault java
- Category
- Java
- Title
- entre clavier java
- Category
- Java
- Title
- add one character to string java
- Category
- Java
- Title
- how get started with LWJGL 3
- Category
- Java
- Title
- is self divisor java
- Category
- Java
- Title
- how to substring in java
- Category
- Java
- Title
- generate random number java
- Category
- Java
- Title
- take a peice from array java
- Category
- Java
- Title
- get raondom from array java
- Category
- Java
- Title
- java create folder
- Category
- Java