GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java/Programs/list_1.java at main · arshcoder13/Java

Expand file tree

/

list_1.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
45 lines (39 loc) · 1.22 KB
/

list_1.java

Copy path

File metadata and controls

45 lines (39 loc) · 1.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
// HW -
// WAP a Java program which will create a list of int, string and decimal numbers using arraylist and linkedlists
public class list_1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Array list for strings -
List<String> listStrings = new ArrayList<String>();
listStrings.add("One");
listStrings.add("Two");
listStrings.add("Three");
listStrings.add("Four");
System.out.println(listStrings);
System.out.println(listStrings.get(1));
listStrings.set(3, "Using set method!");
System.out.println(listStrings);
// Array list for integers -
List<Integer> listIntegers = new ArrayList<Integer>();
listIntegers.add(1);
listIntegers.add(2);
listIntegers.add(3);
listIntegers.add(4);
System.out.println(listIntegers);
// Iterating over a list -
Iterator<Integer> iter = listIntegers.iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
// Linked List for numbers -
LinkedList<Number> numbers = new LinkedList<Number>();
numbers.add(10);
numbers.add(10.32);
numbers.add(45.3333333);
System.out.println(numbers);
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.