Problem Solving with Algorithms

반응형

www.w3schools.com/java/java_class_methods.asp

 

Java Class Methods

Java Class Methods Java Class Methods You learned from the Java Methods chapter that methods are declared within a class, and that they are used to perform certain actions: Example Create a method named myMethod() in MyClass: public class MyClass {   stat

www.w3schools.com

 

 

 

Static vs. Non-Static

스태틱은 오브젝트의 생성과 상관없이 접근가능함.

 

www.w3schools.com/java/java_modifiers.asp

 

Java Modifiers

Java Modifiers Modifiers By now, you are quite familiar with the public keyword that appears in almost all of our examples: The public keyword is an access modifier, meaning that it is used to set the access level for classes, attributes, methods and const

www.w3schools.com

 

 

 

 

Date & time 은 별로 필요없을것 같긴하지만..

 

www.w3schools.com/java/java_date.asp

 

Java Date and Time

Java Date and Time Java Dates Java does not have a built-in Date class, but we can import the java.time package to work with the date and time API. The package includes many date and time classes. For example: Class Description LocalDate Represents a date

www.w3schools.com

 


 

 

 

 

 

www.w3schools.com/java/java_arraylist.asp

 

Java ArrayList

Java ArrayList Java ArrayList The ArrayList class is a resizable array, which can be found in the java.util package. The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you want to add or re

www.w3schools.com

 

c++의 벡터와 차이점이 뭐지?

 

정렬은

ArrayList<String> cars = new ArrayList<String>();

cars.add("Volvo");

Collections.sort(cars);

 

 

www.w3schools.com/java/java_linkedlist.asp

 

Java LinkedList

Java LinkedList Java LinkedList In the previous chapter, you learned about the ArrayList class. The LinkedList class is almost identical to the ArrayList: Example // Import the LinkedList class import java.util.LinkedList; public class MyClass {   public

www.w3schools.com

ArrayList vs. LinkedList

The LinkedList class is a collection which can contain many objects of the same type, just like the ArrayList.

The LinkedList class has all of the same methods as the ArrayList class because they both implement the List interface. This means that you can add items, change items, remove items and clear the list in the same way.

However, while the ArrayList class and the LinkedList class can be used in the same way, they are built very differently.

How the ArrayList works

The ArrayList class has a regular array inside it. When an element is added, it is placed into the array. If the array is not big enough, a new, larger array is created to replace the old one and the old one is removed.

How the LinkedList works

The LinkedList stores its items in "containers." The list has a link to the first container and each container has a link to the next container in the list. To add an element to the list, the element is placed into a new container and that container is linked to one of the other containers in the list.

When To Use

It is best to use an ArrayList when:

  • You want to access random items frequently
  • You only need to add or remove elements at the end of the list

It is best to use a LinkedList when:

  • You only use the list by looping through it instead of accessing random items
  • You frequently need to add and remove items from the beginning or middle of the
  • list

LinkedList Methods

For many cases, the ArrayList is more efficient as it is common to need access to random items in the list, but the LinkedList provides several methods to do certain operations more efficiently:

MethodDescriptionTry it

addFirst() Adds an item to the beginning of the list. Try it »
addLast() Add an item to the end of the list Try it »
removeFirst() Remove an item from the beginning of the list. Try it »
removeLast() Remove an item from the end of the list Try it »
getFirst() Get the item at the beginning of the list Try it »
getLast() Get the item at the end of the list Try it »

 

 


www.w3schools.com/java/java_hashmap.asp

 

Java HashMap

Java HashMap Java HashMap In the ArrayList chapter, you learned that Arrays store items as an ordered collection, and you have to access them with an index number (int type). A HashMap however, store items in "key/value" pairs, and you can access them by a

www.w3schools.com

// Import the HashMap class
import java.util.HashMap;

public class MyClass {
  public static void main(String[] args) {

    // Create a HashMap object called people
    HashMap<String, Integer> people = new HashMap<String, Integer>();


    // Add keys and values (Name, Age)
    people.put("John", 32);
    people.put("Steve", 30);
    people.put("Angie", 33);

    for (String i : people.keySet()) {
      System.out.println("key: " + i + " value: " + people.get(i));
    }
  }
}

 

 

 

import java.util.HashSet;

public class MyClass {
  public static void main(String[] args) {

    // Create a HashSet object called numbers
    HashSet<Integer> numbers = new HashSet<Integer>();

    // Add values to the set
    numbers.add(4);
    numbers.add(7);
    numbers.add(8);

    // Show which numbers between 1 and 10 are in the set
    for(int i = 1; i <= 10; i++) {
      if(numbers.contains(i)) {
        System.out.println(i + " was found in the set.");
      } else {
        System.out.println(i + " was not found in the set.");
      }
    }
  }
}

 

 

 

 

import java.util.ArrayList;
import java.util.Iterator;

public class MyClass {
  public static void main(String[] args) {
    ArrayList<Integer> numbers = new ArrayList<Integer>();
    numbers.add(12);
    numbers.add(8);
    numbers.add(2);
    numbers.add(23);
    Iterator<Integer> it = numbers.iterator();
    while(it.hasNext()) {
      Integer i = it.next();
      if(i < 10) {
        it.remove();
      }
    }
    System.out.println(numbers);
  }
}

 

 

Primitive Data TypeWrapper Class

byte Byte
short Short
int Integer
long Long
float Float
double Double
boolean Boolean
char Character

Sometimes you must use wrapper classes, for example when working with Collection objects, such as ArrayList, where primitive types cannot be used (the list can only store objects):

 

 

public class MyClass {
  public static void main(String[] args) {
    Integer myInt = 5;
    Double myDouble = 5.99;
    Character myChar = 'A';
    System.out.println(myInt.intValue());
    System.out.println(myDouble.doubleValue());
    System.out.println(myChar.charValue());
  }
}

 

 

public class MyClass {
  public static void main(String[] args) {
    Integer myInt = 100;
    String myString = myInt.toString();
    System.out.println(myString.length());
  }
}

 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyClass {
  public static void main(String[] args) {
    Pattern pattern = Pattern.compile("w3schools", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher("Visit W3Schools!");
    boolean matchFound = matcher.find();
    if(matchFound) {
      System.out.println("Match found");
    } else {
      System.out.println("Match not found");
    }
  }
}
// Outputs Match found

 

 

 

www.w3schools.com/java/java_threads.asp

 

Java Threads

Java Threads Java Threads Threads allows a program to operate more efficiently by doing multiple things at the same time. Threads can be used to perform complicated tasks in the background without interrupting the main program. Creating a Thread There are

www.w3schools.com

thread 와 concurrency 도 다시보기

 

www.w3schools.com/java/java_lambda.asp

 

Java Lambda Expressions

Java Lambda Expressions Java Lambda Expressions Lambda Expressions were added in Java 8. A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and

www.w3schools.com

www.w3schools.com/java/java_files.asp

 

Java Files

Java Files File handling is an important part of any application. Java has several methods for creating, reading, updating, and deleting files. Java File Handling The File class from the java.io package, allows us to work with files. To use the File class,

www.w3schools.com

www.w3schools.com/java/java_files_create.asp

 

Java Create and Write To Files

Java Create and Write To Files Create a File To create a file in Java, you can use the createNewFile() method. This method returns a boolean value: true if the file was successfully created, and false if the file already exists. Note that the method is enc

www.w3schools.com

 

 

www.w3schools.com/java/java_files_read.asp

 

Java Read Files

Java Read Files Read a File In the previous chapter, you learned how to create and write to a file. In the following example, we use the Scanner class to read the contents of the text file we created in the previous chapter: Example import java.io.File; 

www.w3schools.com

 

 

 

www.w3schools.com/java/java_files_delete.asp

 

Java Delete Files

Java Delete Files Delete a File To delete a file in Java, use the delete() method: Example import java.io.File;  // Import the File class public class DeleteFile { public static void main(String[] args) { File myObj = new File("filename.txt"); if (myObj.d

www.w3schools.com

 

www.w3schools.com/java/java_howto_add_two_numbers.asp

 

Java How To Add Two Numbers

Java How To Add Two Numbers Add Two Numbers Learn how to add two numbers in Java: Example int x = 5; int y = 6; int sum = x + y; System.out.println(sum); // Print the sum of x + y Run example » Add Two Numbers with User Input Learn how to add two numbers

www.w3schools.com

 

 

www.w3schools.com/java/java_ref_string.asp

 

Java String Reference

Java String Methods All String Methods The String class has a set of built-in methods that you can use on strings. Method Description Return Type charAt() Returns the character at the specified index (position) char codePointAt() Returns the Unicode of the

www.w3schools.com

www.w3schools.com/java/java_ref_math.asp

 

Java Math Reference

Java Math Methods The Java Math class has many methods that allows you to perform mathematical tasks on numbers. All Math Methods A list of all Math methods can be found in the table below: Method Description Return Type abs(x) Returns the absolute value o

www.w3schools.com

 

 

www.w3schools.com/quiztest/result.asp

 

https://www.w3schools.com/quiztest/result.asp

 

www.w3schools.com

25문제 나오는 문제까지 다 풀어버렸넹

 

너무 간단한 내용들이었다..


 

 

갑자기 이걸 왜 본건지는 모르겠으나...

 

dzone.com/articles/20-useful-open-source-libraries-for-java-programme

 

20 Useful Libraries Java Programmers Should Know - DZone Java

This post introduces the top 20 open source libraries that Java programmers should be using, with libraries pertaining to logging, unit testing, HTTP, and more.

dzone.com

 

 

 

 

반응형
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band