Time of Update: 2018-07-27
1.一個升序的數組,求其中的兩個數的和為s的一對數,並且輸出他們,若有多對,則全部輸出 方法一:兩重for迴圈,時間複雜度是n^2,沒有用上升序這個條件 public void moveArray(int[] array, int s) { int n = array.length - 1; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++)
Time of Update: 2018-07-27
Java數組面試題請教一下。 5 下面哪個數組定義是錯誤的。 並對錯誤的答案加上單行注釋,寫出錯誤的原因。 A,float[]=new float[3]; B, float f2[]=new float[]; C, float[] f1=new float[3];。 D, boolean[] b={"true","false","true"};。 E, double
Time of Update: 2018-07-27
一個鏈表中包含環,請找出該鏈表的環的入口結點 class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; }}public class Solution { public ListNode EntryNodeOfLoop(ListNode pHead) {
Time of Update: 2018-07-27
例子說明 在例子中,我們將學習如何分頁顯示使用者的評論。 加入spring data 引入jar包 加入spring data在pom中引入 <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId>
Time of Update: 2018-07-27
1.今天在面試的時候遇到一個程式題,代碼如下: public class test2{public static void main(String[] args){int[] arr=new int[5];//給數群組成員賦值arr[0]=2;arr[3]=5;for (int i = 0; i < arr.length;
Time of Update: 2018-07-27
資料的儲存介質 flat-file entity storage 不同的entity可能存放在不同的目錄,每個entity就是目錄下的一個檔案,名字是代理鍵( surrogate key),也就是索引,方便定位。檔案格式多樣,可能是直接Java對象序列化,可能是XML,JSON。 讀寫entity,需要開啟檔案和關閉檔案,因此效率低下,且不支援代理鍵之外的索引。一般用於儲存少量且基本的資料,例如應用配置。 structured file storage
Time of Update: 2018-07-27
Java集合類架構的基本介面有哪些。區別是什麼。 1.集合的兩大常用架構:Collection介面和Map介面; 1.1Collection介面又有兩個常用的子介面:List介面和Set介面。 1.1.1對List介面有三個常用實作類別:ArrayList類和Vector類,還有LinkedList類。
Time of Update: 2018-07-27
package com.bxh.array;import java.util.ArrayList;import java.util.Arrays;public class findMaxMin {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubint[] arr={1,-2,4,8,-4,7,-1,-5};//findMaxMinS(arr);//int
Time of Update: 2018-07-27
寫此文的目的是複習java中靜態塊、main方法、構造塊、構造方法的執行順序,直接運行下面的代碼即可一目瞭然,不再多說。 /** * 運行父類main方法各個塊範圍的執行順序: * static塊(且僅僅執行一次) -> main方法 -> 構造塊 -> 構造方法 */public class Parent { private int age = 0; private String name = null; private static String
Time of Update: 2018-07-27
ClusterEventMulticaster:自訂的ApplicationEventMulticaster 設定為root內容相關的bean 在root內容相關的設定檔中: @Beanpublic ApplicationEventMulticaster applicationEventMulticaster(){ SimpleApplicationEventMulticaster eventMulticaster = new
Time of Update: 2018-07-27
題目: 如果一個字串由兩個相同字串串連而成,就稱這個字串是偶串。例如"xyzxyz"和"aaaaaa"是偶串,但是"ababab"和"xyzxy"卻不是。牛牛現在給你一個只包含小寫字母的偶串s,你可以從字串s的末尾刪除1和或者多個字元,保證刪除之後的字串還是一個偶串,牛牛想知道刪除之後得到最長偶串長度是多少。 輸入描述: 輸入包括一個字串s,字串長度length(2 ≤ length ≤ 2
Time of Update: 2018-07-27
廢話少說,直接開搞 public class LinkedList<E> extends AbstractSequentialList<E> implements List<E>, Deque<E>, Cloneable, java.io.Serializable{ //元素個數 transient int size = 0; //抽象出來的鏈表節點類 private static class
Time of Update: 2018-07-27
何為事務的isolation isolation對於資料的一致性很重要。網上有很多介紹,推薦閱讀: MYSQL官網 14.5.2.1 Transaction Isolation Levels Hibernate Tutorial 20.7.2 Transaction Isolation Levels
Time of Update: 2018-07-27
歡迎訪問 部落格新址 建立與輸出數組 數組 - 執行個體 - 求一位元組各元素的和 public class Test { public static void main(String[] args) { int[] num = {1,2,3,4,5,6,7,8,9,10}; int sum = 0; System.out.println("一維數組中各元素的和是:"); for
Time of Update: 2018-07-27
CRUD並不足夠 在之前學習中,使用了通用倉庫介面GenericRepository,並通過GenericBaseRepository,GenericJpaRepository來具體實現,實現上對於CRUD而言,這類的實現大同小異,此外,我們還需要根據UNIQUE KEY或者KEY去進行查詢,而不僅僅使用primary key,還有根據多個條件去進行查詢或者檢索,對返回的結果進行分頁等等。GenericRepository提供的基礎CRUD是不足夠的。
Time of Update: 2018-07-27
學習目的 RabbitMQ是AMQP的一個實現。我們將跟隨rabbitMQ官網上的例子,瞭解AMQP所支援的不同訊息佇列模式,以及代碼如何?。 安裝RabbitMQ Server Ubuntu內建的RabbitMQ Server,安裝如下 sudo apt-get install rabbitmq-serversudo service rabbitmq-server startsudo rabbitmq-plugins enable rabbitmq_management
Time of Update: 2018-07-27
歡迎訪問 部落格新址 基礎 定義介面 public interface ICalculate { final float PI=3.14159f; float getArea(float r); float getCircumference(float r);} 實現介面 注意:要實現介面的所有方法(抽象) public class Cire implements ICalculate { /
Time of Update: 2018-07-27
Work Queues:競爭消費模式(competing consumers pattern) 簡單模式,也可以用於多個client(subsriber)去擷取訊息,和簡單模式對比: 我們希望資料能夠真正被client處理完,client處理好後應發送Basic.ACK訊息給server,如果client因為某個原因未能處理好,當channel關閉,connection關閉或中斷的時候,這個訊息應該能夠分配給其他的client進行處理。
Time of Update: 2018-07-27
歡迎訪問 部落格新址 CC150 標籤: 刷題 編程 Java 8.1 1.1 字串互異 確定一個字串的所有字元是否全都不同。 方法一:逐字元比較的方法。時間複雜度: O(n2) O(n^2)。 import java.util.*;public class Different { public boolean checkDifferent(String iniString) {
Time of Update: 2018-07-27
歡迎訪問 部落格新址 條件 條件陳述式 - if public class Test { public static void main(String[] args) { int a = 100; if(a==100) { System.out.println("a的值是 100"); } }} public class Test { public static