Home>Network programming tutorial> Java tutorial
All ASP tutorial ASP tutorial ASP.NET tutorial PHP tutorial JSP tutorial C#/CSHARP tutorial XML tutorial Ajax tutorial Perl tutorial Shell tutorial Visual Basic tutorial Delphi tutorial Mobile development tutorial C/C++ tutorial Java tutorial J2EE/J2ME Software engineering
Java tutorial
  • How to implement random non-repeating numbers in Java

    How to implement random non-repeating numbers in Java

    Generally, friends with some development experience can realize such a function, but it is just a matter of efficiency. When we usually face such a problem, we always think of it in flat order. First, generate an array, and then add random numbers to the
    2024-11-25
  • Analysis of the difference between value transfer and reference transfer in java

    Analysis of the difference between value transfer and reference transfer in java

    Pass value---pass basic data type parameters. Copy the code. The code is as follows: public class PassValue{static void exchange(int a, int b){//Static method, exchange the values ​​​​of a and b int temp;temp = a;a = b;b = temp;}public static void main(St
    2024-11-25
  • Hill sort algorithm code

    Hill sort algorithm code

    The time complexity of Hill sorting is O(n*log2n) and the space complexity is O(1). It is an unstable sorting algorithm idea: Hill sorting is also an insertion sorting method, which is actually a group insertion method. . First, determine an integer d1 le
    2024-11-25
  • Java example code for sending emails (portable)

    Java example code for sending emails (portable)

    Taking a web project as an example, the code is portable. First, import the mail.jar package, and then create your own class 1: HTMLSender class. Copy the code as follows: package com.txq.mail; import java.util.Properties; import javax .mail.Message;impor
    2024-11-25
  • Java Clone (class copy) example code

    Java Clone (class copy) example code

    I implemented it myself: copy the code as follows: public class A implements Cloneable {public String str[];A() {str = new String[2];}public Object clone() {A o = null;try {o = (A) super.clone();} catch (CloneNotSupportedException e) {e.printStackTrace();
    2024-11-25
  • Java binary search method (binary search) example

    Java binary search method (binary search) example

    复制代码代码如下:public class HalfSearch {public static int halfSearch(int a[], int x) {int mid, left, right;left = 0;right = a.length - 1;mid = (left + right) / 2;while (a[mid] != x) {if (x > a[mid]) {left = mid + 1;}else if (x < a[mid]) {right = mid - 1;}
    2024-11-25
  • How to determine the type of local IP address in Java

    How to determine the type of local IP address in Java

    Copy the code as follows: package net; import java.net.*;/** The getAddress method is similar to getHostAddress. The only difference is that the getHostAddress method returns an IP address in the form of a string, * and the getAddress method returns a byt
    2024-11-25
  • Solving the problem of tomcat port 80 being occupied in java

    Solving the problem of tomcat port 80 being occupied in java

    Today I encountered the problem of this port being occupied, and various Baidu first said to use the command netstat -a -n -o. The last option indicates the process ID of the connection. Find the PID of port 8080 and then open the task manager, switch to
    2024-11-25
  • Usage analysis of CyclicBarrier in Java

    Usage analysis of CyclicBarrier in Java

    复制代码代码如下:public class TestCyclicBarrier {private static final int THREAD_NUM = 5;public static class WorkerThread implements Runnable{CyclicBarrier barrier;public WorkerThread(CyclicBarrier b){this.barrier = b;}@Overridepublic void run() {// TODO Auto-gen
    2024-11-25
  • How to solve the problem of modifying the font of StaticText

    How to solve the problem of modifying the font of StaticText

    After checking the information on the Internet, some are relatively comprehensive, but one problem is that it is easy for the text and the frame to not match. (Look carefully, there are gaps between the blue letters and the gray background.) To eliminate
    2024-11-25
  • A small example of java getting the client's Mac address through IP

    A small example of java getting the client's Mac address through IP

    Copy the code as follows: package com.yswc.dao.sign;import java.io.BufferedReader;import java.io.InputStreamReader;import java.util.regex.Matcher;import java.util.regex.Pattern;/*** * Get MAC address* * @author* * 2011-12* */public class GetMacAddress {pu
    2024-11-25
  • How to implement remote login in MySQL

    How to implement remote login in MySQL

    Cause analysis: Host 'Local' is not allowed to connect to this MySQL server. Typical remote permission problem. The crux of the problem: MySQL does not have remote login permissions. It depends on what kind of system your server uses, whether it i
    2024-11-25
  • How to prevent null pointer exceptions in java code

    How to prevent null pointer exceptions in java code

    NullPointerException encountered in the project can be divided into two situations: 1. Referring to a null object, that is, calling a method of a null object or referencing a property of a null object. 2. Assign the encapsulation classes of the basic type
    2024-11-25
  • Java small example of recursively traversing directories

    Java small example of recursively traversing directories

    Copy the code as follows: public static void main(String[] args) {File f = new File("D://test//fsd");listChids(f,0);}public static void listChids(File f, int level){String preSrt = "";for(int i=0;i
    2024-11-25
  • Java method to replace carriage returns and line feeds in strings

    Java method to replace carriage returns and line feeds in strings

    Use regular expressions to replace: Code snippet: String documentTxt = EntityUtils.toString(entity,"gbk");//Get data documentTxt=documentTxt.replaceAll("[//t//n//r]", "" );//Remove the carriage return and line feed in the con
    2024-11-25