Javaaaaaaaaaaaaaaaaaaaaa
This commit is contained in:
parent
6621d48a07
commit
43de41eee1
1
.gitignore
vendored
1
.gitignore
vendored
@ -175,3 +175,4 @@
|
|||||||
/Semester 3/Assignments/MP3_Recursion_CalebFontenot/dist/
|
/Semester 3/Assignments/MP3_Recursion_CalebFontenot/dist/
|
||||||
/BigIntegerFibonacci/nbproject/private/
|
/BigIntegerFibonacci/nbproject/private/
|
||||||
/BigIntegerFibonacci/build/
|
/BigIntegerFibonacci/build/
|
||||||
|
/Semester 3/GenericRules/target/
|
||||||
|
18
Semester 3/GenericRules/nb-configuration.xml
Normal file
18
Semester 3/GenericRules/nb-configuration.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-shared-configuration>
|
||||||
|
<!--
|
||||||
|
This file contains additional configuration written by modules in the NetBeans IDE.
|
||||||
|
The configuration is intended to be shared among all the users of project and
|
||||||
|
therefore it is assumed to be part of version control checkout.
|
||||||
|
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
||||||
|
-->
|
||||||
|
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
||||||
|
<!--
|
||||||
|
Properties that influence various parts of the IDE, especially code formatting and the like.
|
||||||
|
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
||||||
|
That way multiple projects can share the same settings (useful for formatting rules for example).
|
||||||
|
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
||||||
|
-->
|
||||||
|
<netbeans.hint.jdkPlatform>JDK_20__System_</netbeans.hint.jdkPlatform>
|
||||||
|
</properties>
|
||||||
|
</project-shared-configuration>
|
@ -7,8 +7,8 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>20</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>20</maven.compiler.target>
|
||||||
<exec.mainClass>edu.slcc.asdv.caleb.gemericrules.GemericRules</exec.mainClass>
|
<exec.mainClass>edu.slcc.asdv.caleb.gemericrules.GemericRules</exec.mainClass>
|
||||||
</properties>
|
</properties>
|
||||||
<name>GenericRules</name>
|
<name>GenericRules</name>
|
||||||
|
@ -15,6 +15,6 @@ public class GenericRule3 {
|
|||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
List<Number> list1 = new ArrayList<Number>();
|
List<Number> list1 = new ArrayList<Number>();
|
||||||
ArrayList<Number> list2 = new ArrayList<Integer>();
|
//ArrayList<Number> list2 = new ArrayList<Integer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package edu.slcc.asdv.caleb.gemericrules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class GenericRule4 {
|
||||||
|
public static void f1(ArrayList<?> list) {
|
||||||
|
System.out.println(list.size());
|
||||||
|
///list.add(new Integer(5));
|
||||||
|
}
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
f1(new ArrayList<Integer>());
|
||||||
|
f1(new ArrayList<Double>());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package edu.slcc.asdv.caleb.gemericrules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class GenericRule5 {
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
List<?> list1 = new ArrayList<Integer>();
|
||||||
|
ArrayList<?> list2 = new ArrayList<Double>();
|
||||||
|
ArrayList<?> list3 = new ArrayList<String>();
|
||||||
|
//list3.add("abc");
|
||||||
|
System.out.println(list3.size());
|
||||||
|
System.out.println(list3.subList(0, 0));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package edu.slcc.asdv.caleb.gemericrules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import static java.util.Collections.list;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class GenericRule6 {
|
||||||
|
public static void f6(List<? extends A> list) {
|
||||||
|
System.out.println(list.size());
|
||||||
|
}
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
List<A> list1 = new ArrayList<>();
|
||||||
|
list1.add (new C());
|
||||||
|
list1.add (new B());
|
||||||
|
f6(list1);
|
||||||
|
|
||||||
|
ArrayList<B> list2 = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//class A{}
|
||||||
|
//class B extends A{}
|
||||||
|
//class C extends B{}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package edu.slcc.asdv.caleb.gemericrules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import static java.util.Collections.list;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class GenericRule7 {
|
||||||
|
|
||||||
|
public static void f6(List<? extends A> list)
|
||||||
|
{
|
||||||
|
System.out.println(list.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
List<A> list1 = new ArrayList<>();
|
||||||
|
list1.add(new C());
|
||||||
|
list1.add(new B());
|
||||||
|
|
||||||
|
List<? extends A> list = list1;
|
||||||
|
|
||||||
|
ArrayList<B> list2 = new ArrayList<>();
|
||||||
|
list1.add(new A());
|
||||||
|
list = list2;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends A {
|
||||||
|
}
|
||||||
|
|
||||||
|
class C extends B {
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package edu.slcc.asdv.caleb.gemericrules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class GenericRule8<T1> {
|
||||||
|
|
||||||
|
// List<? extends T1> lista = new ArrayList<String>();
|
||||||
|
|
||||||
|
public static <T2> void f8(List<? extends T2> list)
|
||||||
|
{
|
||||||
|
System.out.println(list.size());
|
||||||
|
//list.add(new C());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
list<A> list1 = new ArrayList<>();
|
||||||
|
list1.add(new C());
|
||||||
|
list1.add(new B());
|
||||||
|
f8(list1);
|
||||||
|
|
||||||
|
ArrayList<B> list2 = new ArrayList<>();
|
||||||
|
list2.add(new A());
|
||||||
|
f8(list2);
|
||||||
|
|
||||||
|
ArrayList<String> list3 = new ArrayList<String>();
|
||||||
|
list3.add("abc");
|
||||||
|
f8(list3);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user