使用Java实现2048小游戏代码实例

 更新时间:2023年10月30日 10:33:48   作者:有人_295  
这篇文章主要介绍了使用Java实现2048小游戏代码实例,2048 游戏是一款益智类游戏,玩家需要通过合并相同数字的方块,不断合成更大的数字,最终达到2048,游戏规则简单,但挑战性很高,需要玩家灵活运用策略和计算能力,本文将使用Java代码实现,需要的朋友可以参考下

一、框架

在这里插入图片描述

就以个 2 维数组,4 个方向进行加法 在空白位置出现随机的 2 就行了

二、代码

1、ConstantValue.java(封装常量)

import java.awt.Color;
/*
 * 封装常量
 * WID:边长
 * SP:间隔
 * lable:各种数字
 * clo:对应数字颜色
 * */
public class ConstantValue {
    private static final int WID = 150;
    private static final int SP = 10;
    private static final int[] label = { 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
    private static final Color[] clo = {
            new Color(200, 200, 200), 
            new Color(228, 228, 160),
            new Color(214, 163, 92), 
            new Color(234, 124, 72),
            new Color(240, 84, 77), 
            new Color(255, 68, 53),
            new Color(200, 200, 64),
            new Color(0, 0, 255),
            new Color(0, 255, 0),
            new Color(255, 0, 0),
            new Color(100, 100, 100),
        };
	public static int getWid() {
		return WID;
	}
	public static int getSp() {
		return SP;
	}
	public static int[] getLabel() {
		return label;
	}
	public static Color[] getClo() {
		return clo;
	}
}

2、Game2048.java

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
public class Game2048 extends JApplet {
	private int scores = 0;
    private int best = 0;
    private boolean change;
    private boolean CheckMode = false;
    private boolean gameOverFlag = false;
    private boolean successFlag = false;
    private static JLabel scoreLabel;
    private static My2048Panel myp;
    private static JButton goBackButton;
    public static RectObject[][] rset = new RectObject[4][4];
    private Map<Integer, Color> cmap = new HashMap<Integer, Color>();
    public RectObject[][] list = new RectObject[4][4];
    private LinkedList<ArrayList<Integer>> saveList = new LinkedList<ArrayList<Integer>>();
    KeyListener kl = new KeyListener() {
            public void keyPressed(KeyEvent e) {
                saveTheStep();
                goBackButton.setVisible(true);
                if (gameOverFlag == true) {
                    return;
                }
                if (!aDirAble()) {
                    gameOver();
                }
                int key = e.getKeyCode();
                switch (key) {
                case KeyEvent.VK_UP:
                    change = false;
                    moveUp(true);
                    if (change == true) {
                        getARandomRect();
                        //saveTheStep();
                    }
                    break;
                case KeyEvent.VK_DOWN:
                    change = false;
                    moveDown(true);
                    if (change == true) {
                        getARandomRect();
                        //saveTheStep();
                    }
                    break;
                case KeyEvent.VK_LEFT:
                    change = false;
                    moveLeft(true);
                    if (change == true) {
                        getARandomRect();
                        //saveTheStep();
                    }
                    break;
                case KeyEvent.VK_RIGHT:
                    change = false;
                    moveRight(true);
                    if (change == true) {
                        getARandomRect();
                        //saveTheStep();
                    }
                    break;
                }
                //saveTheStep();
            }
            public void keyTyped(KeyEvent e) {
            }
            public void keyReleased(KeyEvent e) {
            }
        };
    public Game2048() {
        //saveTheStep();
        for (int i = 0; i < 11; i++) {
            cmap.put(ConstantValue.getLabel()[i], ConstantValue.getClo()[i]);
        }
    }
    //the applet init
    public void init() {
        Container cp = getContentPane();
        cp.setLayout(null);
        cp.setFocusable(true);
        cp.addKeyListener(kl);
        Font font = new Font("TimesNewman", Font.BOLD, 30);
        JLabel sl = new JLabel();
        sl.setLayout(new GridLayout(2, 1));
        JLabel sllb = new JLabel("Scores");
        sllb.setFont(font);
        scoreLabel = new JLabel("0");
        scoreLabel.setFont(font);
        sl.add(sllb);
        sl.add(scoreLabel);
        try {
            File file = new File("BestRecord");
            if (file.exists()) {
                RandomAccessFile f = new RandomAccessFile(file, "rw");
                f.seek(0);
                best = f.readInt();
                f.close();
            }
        } catch (FileNotFoundException e) {
            best = 0;
            e.printStackTrace();
        } catch (IOException e) {
            best = 0;
            e.printStackTrace();
        }
        JLabel bsl = new JLabel();
        bsl.setLayout(new GridLayout(2, 1));
        JLabel jl = new JLabel("Best");
        jl.setFont(font);
        JLabel jl1 = new JLabel("" + best);
        jl1.setFont(font);
        bsl.add(jl);
        bsl.add(jl1);
        myp = new My2048Panel();
        LOGO logo = new LOGO(0, 0);
        goBackButton = new JButton("UNDO");
        goBackButton.setFont(font);
        goBackButton.addActionListener(new goBackListener());
        goBackButton.addKeyListener(kl);
        JButton jb = new JButton("RESET");
        jb.setFont(font);
        jb.addActionListener(new resetListener());
        jb.addKeyListener(kl);
        sl.setBounds(500, 20, 200, 80);
        bsl.setBounds(300, 20, 200, 80);
        logo.setBounds(0, 0, 600, 100);
        myp.setBounds(0, 90, 700, 700);
        goBackButton.setBounds(700, 250, 150, 60);
        jb.setBounds(700, 450, 150, 60);
        cp.add(sl);
        cp.add(bsl);
        cp.add(logo);
        cp.add(myp);
        cp.add(goBackButton);
        cp.add(jb);
        File f = new File("LastRecord");
        if (f.exists()) {
            try {
                RandomAccessFile file = new RandomAccessFile(f, "rw");
                int num = file.readInt();
                scoreLabel.setText("" + num);
                for (int i = 0; i < 4; i++) {
                    for (int j = 0; j < 4; j++) {
                        num = file.readInt();
                        if (num != 0) {
                            rset[i][j] = new RectObject();
                            rset[i][j].value = num;
                        }
                    }
                }
                file.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            getARandomRect();
            getARandomRect();
        }
    }
    //moveLeft
    public void moveLeft(boolean flag) {
        clearList(list);
        for (int i = 0; i < 4; i++) {
            int k = 0;
            for (int j = 0; j < 4; j++) {
                if (rset[i][j] != null) {
                    list[i][k++] = new RectObject(rset[i][j]);
                }
            }
        }
        for (int i = 0; (i < 4) && flag; i++) {
            for (int j = 0; j < 3; j++) {
                if ((list[i][j] != null) && (list[i][j + 1] != null) &&
                        (list[i][j].value == list[i][j + 1].value)) {
                    list[i][j].value *= 2;
                    if (CheckMode == false) {
                        int sum = Integer.parseInt(scoreLabel.getText());
                        sum += list[i][j].value;
                        scoreLabel.setText("" + sum);
                    }
                    list[i][j + 1] = null;
                    j++;
                }
            }
        }
        if (isChange()) {
            if (CheckMode == false) {
                copySet(rset, list);
                repaint();
                moveLeft(false);
            }
            change = true;
        } else {
            repaint();
        }
    }
    //moveRight
    public void moveRight(boolean flag) {
        clearList(list);
        for (int i = 0; i < 4; i++) {
            int k = 3;
            for (int j = 3; j > -1; j--) {
                if (rset[i][j] != null) {
                    list[i][k--] = new RectObject(rset[i][j]);
                }
            }
        }
        for (int i = 0; (i < 4) && flag; i++) {
            for (int j = 3; j > 0; j--) {
                if ((list[i][j] != null) && (list[i][j - 1] != null) &&
                        (list[i][j].value == list[i][j - 1].value)) {
                    list[i][j].value *= 2;
                    if (CheckMode == false) {
                        int sum = Integer.parseInt(scoreLabel.getText());
                        sum += list[i][j].value;
                        scoreLabel.setText("" + sum);
                    }
                    list[i][j - 1] = null;
                    j--;
                }
            }
        }
        if (isChange()) {
            if (CheckMode == false) {
                copySet(rset, list);
                repaint();
                moveRight(false);
            }
            change = true;
        } else {
            repaint();
        }
    }
    //moveup
    public void moveUp(boolean flag) {
        clearList(list);
        for (int j = 0; j < 4; j++) {
            int k = 0;
            for (int i = 0; i < 4; i++) {
                if (rset[i][j] != null) {
                    list[k++][j] = new RectObject(rset[i][j]);
                }
            }
        }
        for (int j = 0; (j < 4) && flag; j++) {
            for (int i = 0; i < 3; i++) {
                if ((list[i][j] != null) && (list[i + 1][j] != null) &&
                        (list[i][j].value == list[i + 1][j].value)) {
                    list[i][j].value *= 2;
                    if (CheckMode == false) {
                        int sum = Integer.parseInt(scoreLabel.getText());
                        sum += list[i][j].value;
                        scoreLabel.setText("" + sum);
                    }
                    list[i + 1][j] = null;
                    i++;
                }
            }
        }
        if (isChange()) {
            if (CheckMode == false) {
                copySet(rset, list);
                repaint();
                moveUp(false);
            }
            change = true;
        } else {
            repaint();
        }
    }
    //movedown
    public void moveDown(boolean flag) {
        clearList(list);
        for (int j = 0; j < 4; j++) {
            int k = 3;
            for (int i = 3; i > -1; i--) {
                if (rset[i][j] != null) {
                    list[k--][j] = new RectObject(rset[i][j]);
                }
            }
        }
        for (int j = 0; (j < 4) && flag; j++) {
            for (int i = 3; i > 0; i--) {
                if ((list[i][j] != null) && (list[i - 1][j] != null) &&
                        (list[i][j].value == list[i - 1][j].value)) {
                    list[i][j].value *= 2;
                    if (CheckMode == false) {
                        int sum = Integer.parseInt(scoreLabel.getText());
                        sum += list[i][j].value;
                        scoreLabel.setText("" + sum);
                    }
                    list[i - 1][j] = null;
                    i--;
                }
            }
        }
        if (isChange()) {
            if (CheckMode == false) {
                copySet(rset, list);
                repaint();
                moveDown(false);
            }
            change = true;
        } else {
            repaint();
        }
    }
    //other functions
    private void copySet(RectObject[][] dst, RectObject[][] src) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                dst[i][j] = src[i][j];
            }
        }
    }
    //detect whether rset is different from list or not 
    private boolean isChange() {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if ((rset[i][j] != null) && (list[i][j] != null) && !rset[i][j].equals(list[i][j])) {
                    return true;
                }
                if ((rset[i][j] != null) && (list[i][j] == null)) {
                    return true;
                }
                if ((rset[i][j] == null) && (list[i][j] != null)) {
                    return true;
                }
            }
        }
        return false;
    }
    private void clearList(RectObject[][] s) {
        for (int i = 0; i < s.length; i++) {
            for (int j = 0; j < s[i].length; j++) {
                s[i][j] = null;
            }
        }
    }
    //get a random rectangle
    public void getARandomRect() {
        ArrayList<Point> list = new ArrayList<Point>();
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (rset[i][j] == null) {
                    list.add(new Point(i, j));
                }
            }
        }
        if ((list.size() == 0) && !aDirAble()) {
            gameOver();
            return;
        }
        Random rand = new Random();
        int index = rand.nextInt(list.size());
        Point loc = (Point) list.get(index);
        index = rand.nextInt(2);
        rset[loc.x][loc.y] = new RectObject();
        if (index == 1) {
            rset[loc.x][loc.y].value = 4;
        } else {
            rset[loc.x][loc.y].value = 2;
        }
    }
    //detect whether there are other steps or not
    public boolean aDirAble() {
        CheckMode = true;
        change = false;
        moveLeft(true);
        moveRight(true);
        moveDown(true);
        moveUp(true);
        CheckMode = false;
        if (change == true) {
            return true;
        } else {
            return false;
        }
    }
    public void gameOver() {
        gameOverFlag = true;
        JPanel jl = new GameOverPane(myp.getWidth(), myp.getHeight());
        jl.setBounds(0, 0, 700, 700);
        JButton jb1 = new JButton("Again");
        Font font = new Font("TimesRoman", Font.BOLD, 30);
        jb1.setOpaque(false);
        jb1.setFont(font);
        JButton jb2 = new JButton("Close");
        jb2.setSize(jb1.getSize());
        jb2.setOpaque(false);
        jb2.setFont(font);
        //保存最高分,分数重置
        jb1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    refreshBest();
                    scoreLabel.setText("0");
                    myp.remove(jl);
                    clearList(rset);
                    myp.validate();
                    getARandomRect();
                    getARandomRect();
                    repaint();
                    gameOverFlag = false;
                }
            });
        //保存最后结果
        jb2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    refreshBest();
                    File f = new File("LastRecord");
                    if (f.exists()) {
                        f.delete();
                    }
                    System.exit(0);
                }
            });
        jl.add(jb1);
        jl.add(jb2);
        myp.add(jl);
        jl.validate();
    }
    public void gameSuccess() {
        JPanel jl = new SuccessPane(myp.getWidth(), myp.getHeight());
        jl.setOpaque(false);
        jl.setBounds(0, 0, 700, 700);
        JButton jb1 = new JButton("Continue");
        Font font = new Font("TimesRoman", Font.BOLD, 30);
        jb1.setOpaque(false);
        jb1.setFont(font);
        JButton jb2 = new JButton("Close");
        jb2.setSize(jb1.getSize());
        jb2.setOpaque(false);
        jb2.setFont(font);
        jb1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    myp.remove(jl);
                    myp.validate();
                    repaint();
                }
            });
        jb2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    refreshBest();
                    System.exit(0);
                }
            });
        jl.add(jb1);
        jl.add(jb2);
        myp.add(jl);
        jl.validate();
    }
    public void saveTheStep() {
        if (saveList.size() < 20) {
            ArrayList<Integer> arr = new ArrayList<Integer>();
            int score = Integer.parseInt(scoreLabel.getText());
            arr.add(score);
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    if (rset[i][j] != null) {
                        arr.add(rset[i][j].value);
                    } else {
                        arr.add(0);
                    }
                }
            }
            saveList.addLast(arr);
        } else {
            saveList.removeFirst();
            saveTheStep();
        }
    }
    public static String title(Object o) {
        String t = o.getClass().toString();
        if (t.indexOf("class") != -1) {
            t = t.substring(6);
        }
        return t;
    }
    public static void refreshBest() {
        try {
            int best;
            File f = new File("BestRecord");
            RandomAccessFile file;
            if (f.exists()) {
                file = new RandomAccessFile(f, "rw");
                best = file.readInt();
            } else {
                file = new RandomAccessFile(f, "rw");
                best = 0;
            }
            //			System.out.println("The Best score is "+best);
            int cur = Integer.parseInt(scoreLabel.getText());
            if (cur > best) {
                file.seek(0);
                file.writeInt(cur);
            }
            file.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }
    public static void saveRecord() {
        try {
            RandomAccessFile file = new RandomAccessFile(new File("LastRecord"),
                    "rw");
            int score = Integer.parseInt(scoreLabel.getText());
            file.writeInt(score);
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    if (rset[i][j] != null) {
                        file.writeInt(rset[i][j].value);
                    } else {
                        file.writeInt(0);
                    }
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void run(JApplet applet, int width, int height) {
        JFrame frame = new JFrame(title(applet));
        frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    saveRecord();
                    refreshBest();
                    //System.out.println("The score is "+scoreLabel.getText());
                }
            });
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(applet);
        frame.setSize(width, height);
        applet.init();
        applet.start();
        frame.setVisible(true);
    }
    public static void main(String[] args) {
        run(new Game2048(), 900, 800);
    }
    class RectObject {
        private int value;
        public RectObject() {
            value = 0;
        }
        public RectObject(RectObject obj) {
            value = obj.value;
        }
        public boolean equals(Object inobj) {
            RectObject obj = (RectObject) inobj;
            if (obj.value == value) {
                return true;
            }
            return false;
        }
    }
    class Point {
        int x;
        int y;
		public Point(int i, int j) {
            x = i;
            y = j;
        }
    }
    class My2048Panel extends JPanel {
        private int[] xindex = {
        		ConstantValue.getSp(), 
        		(2 * ConstantValue.getSp()) + ConstantValue.getWid(), 
        		(3 * ConstantValue.getSp()) + (2 * ConstantValue.getWid()), 
        		(4 * ConstantValue.getSp()) + (3 * ConstantValue.getWid())
            };
        private int[] yindex = {
                ConstantValue.getSp(), 
                (2 * ConstantValue.getSp()) + ConstantValue.getWid(), 
                (3 * ConstantValue.getSp()) + (2 * ConstantValue.getWid()), 
                (4 * ConstantValue.getSp()) + (3 * ConstantValue.getWid())
            };
        public void paintComponent(Graphics g) {
            //background
            super.paintComponent(g);
            for (int i = 0; i < xindex.length; i++) {
                for (int j = 0; j < yindex.length; j++) {
                    g.setColor(Color.WHITE);
                    g.drawRoundRect(
                    		xindex[i], yindex[j], 
                    		ConstantValue.getWid(), ConstantValue.getWid(), 
                    		ConstantValue.getWid() / 5, ConstantValue.getWid() / 5);
                    g.setColor(new Color(197, 183, 129));
                    g.fillRoundRect(
                    		xindex[i], yindex[j], 
                    		ConstantValue.getWid(), ConstantValue.getWid(), 
                    		ConstantValue.getWid() / 5, ConstantValue.getWid() / 5);
                }
            }
            //paint rectangle
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    if (rset[i][j] != null) {
                        g.setColor(Color.WHITE);
                        g.drawRoundRect(yindex[j], xindex[i], ConstantValue.getWid(), ConstantValue.getWid(),
                            ConstantValue.getWid() / 5, ConstantValue.getWid() / 5);
                        //各数字颜色
                        g.setColor((Color) cmap.get(rset[i][j].value));
                        g.fillRoundRect(yindex[j], xindex[i], ConstantValue.getWid(), ConstantValue.getWid(),
                            ConstantValue.getWid() / 5, ConstantValue.getWid() / 5);
                        g.setColor(Color.BLACK);
                        Font font = new Font("TimesRoman", Font.BOLD, 50);
                        g.setFont(font);
                        FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
                        int len = fm.stringWidth("" + rset[i][j].value);
                        int hg = fm.getHeight();
                        g.drawString("" + rset[i][j].value,
                            (yindex[j] + (ConstantValue.getWid() / 2)) - (len / 2), xindex[i] + (ConstantValue.getWid() / 2) + (hg / 4));
                        if ((rset[i][j].value == 2048) && (successFlag == false)) {
                            successFlag = true;
                            gameSuccess();
                        }
                    }
                }
            }
        }
    }
    class GameOverPane extends JPanel {
        public GameOverPane(int w, int h) {
            setSize(w, h);
        }
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Font font = new Font("TimesRoman", Font.BOLD, 80);
            g.setFont(font);
            FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
            int width = fm.stringWidth("Game Over");
            int height = fm.getHeight();
            g.setColor(new Color(255, 0, 0));
            g.drawString("Game Over!", (getWidth() / 2) - (width / 2),
                (getHeight() / 2) - (height / 2));
        }
    }
    class SuccessPane extends JPanel {
        public SuccessPane(int w, int h) {
            setSize(w, h);
        }
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Font font = new Font("TimesRoman", Font.BOLD, 80);
            g.setFont(font);
            FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
            int width = fm.stringWidth("Success!");
            int height = fm.getHeight();
            g.setColor(new Color(255, 0, 0));
            g.drawString("Success!", (getWidth() / 2) - (width / 2),
                (getHeight() / 2) - (height / 2));
        }
    }
    class LOGO extends JPanel {
        public LOGO(int w, int h) {
            setSize(w, h);
        }
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Font font = new Font("TimesRoman", Font.BOLD, 60);
            g.setFont(font);
            FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
            int width = fm.stringWidth("2048");
            int height = fm.getHeight();
            g.setColor(new Color(255, 0, 0));
            g.drawString("2048", 20, (getHeight() / 2) + 20);
        }
    }
    public class goBackListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            if (saveList.size() == 0) {
                goBackButton.setVisible(false);
                return;
            }
            ArrayList arr = (ArrayList) saveList.getLast();
            scoreLabel.setText("" + arr.get(0));
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    int num = (int) arr.get((4 * i) + j + 1);
                    if (num != 0) {
                        rset[i][j] = new RectObject();
                        rset[i][j].value = num;
                    } else {
                        rset[i][j] = null;
                    }
                }
            }
            saveList.removeLast();
            repaint();
        }
    }
    public class resetListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            refreshBest();
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    rset[i][j] = null;
                }
            }
            scoreLabel.setText("0");
            repaint();
            getARandomRect();
            getARandomRect();
        }
    }
}

三、界面

在这里插入图片描述

到此这篇关于使用Java实现2048小游戏代码实例的文章就介绍到这了,更多相关Java实现2048小游戏内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Spring boot通过切面,实现超灵活的注解式数据校验过程

    Spring boot通过切面,实现超灵活的注解式数据校验过程

    这篇文章主要介绍了Spring boot通过切面,实现超灵活的注解式数据校验过程,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-12-12
  • 简单了解JavaBean作用及常用操作

    简单了解JavaBean作用及常用操作

    这篇文章主要介绍了简单了解JavaBean作用及常用操作,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-05-05
  • Java内部类的继承(全)

    Java内部类的继承(全)

    这篇文章主要介绍了Java内部类的继承,大家都知道JAVA内部类的构造器必须连接指向其外围类对象的引用,所以在继承内部类的时候,需要在导出类的构造器中手动加入对基类构造器的调用,需要的朋友可以参考下
    2015-07-07
  • 关于Feign调用服务Headers传参问题

    关于Feign调用服务Headers传参问题

    这篇文章主要介绍了关于Feign调用服务Headers传参问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-03-03
  • Apache Commons Imaging处理图像实例深究

    Apache Commons Imaging处理图像实例深究

    这篇文章主要为大家介绍了Apache Commons Imaging处理图像的实例探索深究,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-12-12
  • Java中反射reflect的基础知识讲解

    Java中反射reflect的基础知识讲解

    这篇文章主要介绍了Java中反射reflect的基础知识讲解,Java中的反射,它算是Java当中非常底层的一个技术,平时我们我们用得不多,实际上它也的确非常复杂同时也难以理解,但是涉及到底层的东西Java都给我们封装好了,我们直接拿来调用即可,需要的朋友可以参考下
    2023-10-10
  • Servlet映射路径匹配解析详解

    Servlet映射路径匹配解析详解

    servlet是javaweb用来处理请求和响应的重要对象,本文将从源码的角度分析tomcat内部是如何根据请求路径匹配得到处理请求的servlet的,感兴趣的可以了解一下
    2022-08-08
  • Mybatis-Plus saveBatch()批量保存失效的解决

    Mybatis-Plus saveBatch()批量保存失效的解决

    本文主要介绍了Mybatis-Plus saveBatch()批量保存失效的解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-01-01
  • java如何将int数组转化为Integer数组

    java如何将int数组转化为Integer数组

    这篇文章主要介绍了java如何将int数组转化为Integer数组,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-11-11
  • 详解Maven打包和运行

    详解Maven打包和运行

    这篇文章主要介绍了Maven打包和运行的相关知识,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-07-07

最新评论