Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Bi-Weekly
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arsam Ali
Bi-Weekly
Commits
590df624
Commit
590df624
authored
Feb 02, 2023
by
Arsam Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new code
parent
bea41c20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
266 additions
and
13 deletions
+266
-13
Main.java
src/Main.java
+266
-13
No files found.
src/Main.java
View file @
590df624
import
java.util.ArrayList
;
import
java.util.Hashtable
;
import
java.util.Scanner
;
import
java.util.Vector
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
//int x = 5;
// public static void main(String[] args) {
// Main myObj = new Main();
// System.out.println(myObj.x);
// }
// }
//collections
// int[] arr = {12,13,14,15,16};
...
...
@@ -14,17 +29,255 @@ public class Main {
// System.out.println(s);
// }
int
[]
arr
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
122
};
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
if
(
arr
[
i
]%
2
==
0
)
{
System
.
out
.
println
(
arr
[
i
]);
}
else
{
System
.
out
.
println
(
arr
[
i
]+
"others are here"
);
}
}
// int [] arr = {1,2,3,4,5,6,7,8,9,122};
// for (int i = 0; i<arr.length; i++)
// {
// if (arr[i]%2==0) {
// System.out.println(arr[i]);
// }
// else
// {
// System.out.println(arr[i]+ "others are here");
// }
// }
//Accessing Attributes
// double x = 12.8;
//
// public static void main(String[] args) {
// Main myObj = new Main();
// System.out.println(myObj.x);
// }
//override existing values:
// int x = 10;
//
// public static void main(String[] args) {
// Main myObj = new Main();
// myObj.x = 25;
// System.out.println(myObj.x);
// }
//Methods
// static void myMethod() {
// System.out.println("Java practice");
// }
//
// public static void main(String[] args) {
// myMethod();
// }
//static and public methods
// static void myStaticMethod() {
// System.out.println("Static method");
// }
//
// // Public method
// public void myPublicMethod() {
// System.out.println("Public method");
// }
//
// // Main method
// public static void main(String[] args) {
// myStaticMethod();
// // myPublicMethod(); This would compile an error
//
// Main myObj = new Main();
// myObj.myPublicMethod();
// }
// Create a fullThrottle() method
// public void fullSpeed() {
// System.out.println("The car is going as fast as it can!");
// }
//
// // Create a speed() method and add a parameter
// public void speed(int maxSpeed) {
// System.out.println("Max speed is: " + maxSpeed);
// }
//
// public static void main(String[] args) {
// Main myCar = new Main();
// myCar.fullSpeed();
// myCar.speed(600);
// }
//CONSTRUCTORS
// int x;
// public Main() {
// x = 5;
// }
//
// public static void main(String[] args) {
// Main myObj = new Main();
// System.out.println(myObj.x);
// }
//}
//Parameter constructors
// int z;
//
// int s;
// public Main(int y) {
// z = y*2;
// }
//
// public static void main(String[] args) {
// Main myObj = new Main(5);
// System.out.println(myObj.z);
// }
//}
// int modelYear;
// String modelName;
//
// String type;
//
// public Main(int year, String name,String Type) {
// modelYear = year;
// modelName = name;
// type = Type;
// }
//
//public static void main(String[] args) {
// Main myCar = new Main(1969, "Mustang","American");
// System.out.println(myCar.modelYear + " " + myCar.modelName + " " +myCar.type);
// }
//DECISION MAKING
// int time = 22;
// if (time < 10) {
// System.out.println("Good morning.");
// } else if (time < 18) {
// System.out.println("Good day.");
// } else {
// System.out.println("Good evening.");
// }
//
// int day = 3;
// switch (day) {
// case 1:
// System.out.println("Monday");
// break;
// case 2:
// System.out.println("Tuesday");
// break;
// case 3:
// System.out.println("Wednesday");
// break;
// case 4:
// System.out.println("Thursday");
// break;
// case 5:
// System.out.println("Friday");
// break;
// case 6:
// System.out.println("Saturday");
// break;
// case 7:
// System.out.println("Sunday");
// break;
// }
// }
//default keyword with switch
// int day = 4;
// switch (day) {
// case 6:
// System.out.println("Today is wednesday");
// break;
// case 7:
// System.out.println("Today is Thursday");
// break;
// case 8:
// System.out.println("Today is Friday");
// default:
// System.out.println("Looking forward to the Weekend");
// }
//control statements
// int i = 0;
// do {
// System.out.println(i);
// i++;
// }
// while (i < 5);
// int i = 1, n = 5;
//
// while(i <= n) {
// System.out.println(i);
// i++;
// }
// int sum = 0;
// int number = 0;
//
// Scanner input = new Scanner(System.in);
//
// do {
// sum += number;
// System.out.println("Enter a number");
// number = input.nextInt();
// }
// while(number >= 0);
//
// System.out.println("Sum = " + sum);
// input.close();
// }
//Logic buildings
//Fibonacci Without Recursion
// int number1=0, number2=1, number3, i, count=5;
//
// System.out.print(number1+" "+number2);
//
// for(i=2; i<count; ++i)
// {
// number3 = number1+number2;
// System.out.print(" "+number3);
// number1 = number2;
// number2 = number3;
// }
// public static void main(String[] args) {
//
// int arr[] = new int[] { 4,3,7,1};
//// arraylist;
//// linkedlist;
//// queue;
//// set;
//// map;
//// hashmap;
//
// ArrayList<String> a = new ArrayList<String>();
// a.add("Arsam");
// a.add("qms");
// a.add("umer");
// a.remove(2);
// a.get(2);
}
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment