Javascript  
 
  ScriptJava  
 
  Perl  
 
  PHP  
 
  ROR  
 
  ask us  
 

 

Applications
  1. Getting started
  2. Definitions
  3. First program
  4. Characters and Strings
  5. Object and methods
  6. Arrays and Circles
  7. Exceptions
  8. The main method
  9. Reading
  10. Writing file
  11. Vectors
  12. Stacks
  13. Map The Dictionary
  14. Lists
  15. Linked lists
  16. Collection
  17. Interfaces
  18. Scanner
  19. StringTokenizer
  20. Generics
  21. JDBC
  22. DataBase Queries
  23. JSP, The main step

Graphics

Applets
  1. Regards
  2. One Picture
  3. Calculator
  4. Random pictures
  5. Bouncing picture

Swings
  1. Buttons listeners
  2. TextFields
  3. Swing Example

JavaBeans
  1. The first step
  2. Example

Search a word:
   



© The scientific sentence. 2010

Java Circles Arrays
About lists               The colored to comment.



import java.util.*;

public class TheLists 
{
public static void main(String [] args) 
{
List  TheList1 = new ArrayList  ();

System.out.println("\n\tHow is the list TheList filled:");
System.out.println("\n\t" + TheList1);

TheList1.add("1");
TheList1.add("2");
TheList1.add("3");
TheList1.add("4");
TheList1.add("4");
TheList1.add("5");
System.out.println("\n\tWe added elemnts in the list TheList1 :");
System.out.println("\n\t" + TheList1);

swap(TheList1,0,4);
System.out.println("\n\tWe swapped the First and the Fifth 
elements in the ist TheList1 :");
System.out.println("\n\t" + TheList1);	

swap(TheList1,2,3);
System.out.println("\n\tWe swapped the Third and the Fourth 
elements fron the latter list :");
System.out.println("\n\t" + TheList1);

Collections.shuffle(TheList1) ;
System.out.println("\n\tWe shuffled the latter list :");
System.out.println("\n\t" + TheList1);

Collections.reverse(TheList1) ;
System.out.println("\n\tWe reversed the latter list :");
System.out.println("\n\t" + TheList1);
	
Collections.reverse(TheList1) ;
System.out.println("\n\tWe reversed the latter list :");
System.out.println("\n\t" + TheList1);

System.exit(0);



}

public static void swap(List  a, int i, int j) 
{
Object tempo = a.get(i);
a.set(i, a.get(j));
a.set(j, tempo);
}
}


 Execution:

C:\Java>java TheLists

	 How is the list TheList filled:

	[]

	 We added elemnts in the list TheList1 :

	[1, 2, 3, 4, 4, 5]

	 We swapped the First and the Fifth elements in the ist TheList1 :

	[4, 2, 3, 4, 1, 5]

	 We swapped the Third and the Fourth elements fron the latter list :

	[4, 2, 4, 3, 1, 5]

	 We shuffled the latter list :

	[4, 1, 2, 5, 3, 4]

	 We reversed the latter list :

	[4, 3, 5, 2, 1, 4]

	 We reversed the latter list :

	[4, 1, 2, 5, 3, 4]

C:\Java>





  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.