java基礎程序設計
㈠ java語言程序設計基礎篇
視頻的話,可以看郝斌的教程! 很基礎
㈡ JAVA程序設計(基礎篇)
基類 交通工具Vehicle, 擁有方法registerOwner(Human owner),unregisterOwner(Human preOwner),isOwnBy(Human someone) 屬性color和band,band的類可以是一個枚舉Band 子類 汽車專Car 和 自行車Bike 分別實現屬這三個方法,其中要實現人數限制, Car有自己的屬性 前燈左右 和 Engine 類人Human,有一個私有屬性名為vehicles的List,放Vehicle。有專門的方法addVehicle(Vehicle vehicle)和removeVehicle(Vehicle vehicle),其中調用了registerOwner和unregisterOwner。 有屬性年齡age,性別gender, 名字name, gender應屬於枚舉類型Gender
求點贊
㈢ java語言程序設計基礎篇(第十版)pdf
㈣ java語言程序設計基礎篇10.1
外文書名: Introction to Java Programming,Eighth Edition
叢書名: 經典原版書庫
ISBN: 9787111361220
條形碼: 9787111361220
商品尺寸: 24.2 x 17 x 2.6 cm
商品重量: 930 g
品牌: 機械工業出版社
ASIN: B0067GIPKS
B0067GIPKS
2作者簡介編輯
作者:(美)梁
3目錄編輯
Chapter 1 Introction to Computers,Programs,and Java
Chapter 2 Elementary Programming
Chapter 3 Selections
Chapter 4 Loops
Chapter 5 Methods
Chapter 6 Single-Dimensional Arrays
Chapter 7 Multidimensional Arrays
Chapter 8 Objects and Classes
Chapter 9 Strings and Text I/O
Chapter 10 Thinking in Objects
Chapter 11 Inheritance and Polymorphism
Chapter 12 Gui Basics
Chapter 13 Exception Handling
Chapter 14 Abstract Classes and Interfaces
Chapter 15 Graphics
Chapter 16 Event-Driven Programming
Chapter 17 Creating Graphical User Interfaces
Chapter 18 Applets and Multimedia
Chapter 19 Binary I/O
Chapter 20 Recursion
Chapter 21 Generics
Chapter 22 Java Collections Framework
Chapter 23 Algorithm Efficiency
Chapter 24 Sorting
Chapter 25 Lists,Stacks,Queues,and Priority Queues
Chapter 26 Binary Search Trees
Chapter 27 Graphs and Applications
Chapter 28 Weighted Graphs and Applications
Chapter 29 Multithreading
Chapter 30 Networking
Chapter 31 Internationalization
Chapter 32 JavaBeans and Bean Events
Chapter 33 Containers,Layout Managers,and Borders
Chapter 34 Menus,Toolbars,and Dialogs
Chapter 35 MVC and Swing Models
Chapter 36 JTable and JTree
Chapter 37 Java Database Programming
Chapter 38 Advanced Java Database Programming
Chapter 39 Servlets
Chapter 40 JavaServer Pages
Chapter 41 JSF and Visual Web Development
Chapter 42 Web Services
Chapter 43 Remote Method Invocation
Chapter 44 Java 2D
Chapter 45 AVL Trees and Splay Trees
Chapter 46 2-4 Trees and B-Trees
Chapter 47 Red-Black Trees
Chapter 48 Hashing
Appendixes
INDEX
希望能夠幫助到你,望點贊!
㈤ java基本程序設計
/***** 1
* 用 Scanner 從標准輸入讀取數據很方便。 用三目操作符定義求階乘的函數很簡潔。
*
import java.util.Scanner;
class Factorial {
public static int factorial( int n ) {
return n < 2 ? 1 : n * factorial( n - 1 );
}
public static void main( String[ ] args ) {
int sumOfFactorial = 0,
n = new Scanner( System.in ).nextInt( );
while ( n > 0 )
sumOfFactorial += factorial( n-- );
System.out.println( sumOfFactorial );
}
}
*/
/***** 2
* 把空字元串和整數(或任何其它類型)加起來是把後者轉換成字元串的最簡便方法。
* StringBuffer 的反轉方法 reverse( ) 很適合用在這一道題上。
*
class MirrorNumber {
public static void main( String[ ] args ) {
for ( int i = 1000; i <= 9999; i++ )
if ( ( "" + i * 9 ).contentEquals( new StringBuffer( "" + i ).reverse( ) ) )
System.out.println( i );
}
}
*/
/***** 3
* 這一題可以利用正則表達式把字元串中的所有一個或多個連貫的非字母替換成一個空格,
* 讓單詞與單詞之間只有一個空格,然後用 trim( ) 去掉可能存在的前導空格之後,
* 用 split( " " ) 對准所有空格下刀獲取單詞數組。
*
* 前導空格不去掉的話,split( " " ) 返回的字元串數組會以空字元串為第一個元素。
*
* 統計方面,單詞數組的長度既是單詞總數。最長長度和最短長度因為有 TreeSet 助陣而
* 輕松獲得。(TreeSet 中文文檔:http://shorterlink.com/?ZSQJYU )
*
import java.util.*;
class WordStatistics {
public static void printStatistics( String s ) {
String[ ] words = s.replaceAll( "[^a-zA-Z]+", " " ).trim( ).split( " " );
if ( words.length > 0 ) {
double totalLengthOfWords = 0;
TreeSet<Integer> lengths = new TreeSet<Integer>( );
for ( String word: words ) {
lengths.add( word.length( ) );
totalLengthOfWords += word.length( );
}
System.out.println("單詞總數:" + words.length +
"\n最長長度:" + lengths.last( ) +
"\n最短長度:" + lengths.first( ) +
"\n平均長度:" + totalLengthOfWords / words.length );
}
else
System.out.println( "沒有單詞" );
}
public static void main( String[ ] args ) {
printStatistics( "ab+12cd*123fdfg%^&()as23BG" );
}
}
*/
㈥ java入門程序設計
public class OutInfo
{
private String brand;
private double weight;
private String type;
private double price;
OutInfo(String brand, double weight, String type, double price)
{
this.brand = brand;
this.weight = weight;
this.type = type;
this.price = price;
}
public String toString()
{
return "品牌:"+brand+" 重量:"+weight+" 類型:"+type+" 價格:"+price;
}
public static void main(String[] args)
{
//OutInfo oi = new OutInfo("愛國者F928 ",12.4,"內置鋰電池",499);
System.out.println( new OutInfo("愛國者F928 ",12.4,"內置鋰電池",499));
}
}
㈦ Java程序設計基礎知識
《Java程序設計基礎實驗指導(第3版)》是陳國君教授主編的《java程序設計基礎(第3版)》(清華大學出版內社,2011年版)一書的配套實驗容用書。
全書分16章,基本與《java程序設計基礎(第3版)》中的16章一一對應,88個實驗詳細講解了java語言的各個部分。書中的每個實驗都給出了實例以及具體的上機指導,內容由淺入深、循序漸進,知識點全面。實驗有目的地針對學習java語言過程中遇到的重點和難點,強調實用性和易學性,可以幫助讀者進一步熟悉和掌握java語言的語法知識及程序設計的方法。
㈧ JAVA基礎程序設計
題目1:
import java.util.Scanner; /** * 題目1:編寫JAVA應用程序,比較命令行中給出的字元串是否相等,並輸出比較的結果。 * @author Retror * */public class TestEqual { public static String str[]=new String[2]; public static void main(String[] args) { Scanner scan=new Scanner(System.in); for(int i=0;i<str.length;i++){ str[i]=scan.nextLine(); } if(str[0].equals(str[1])){ System.out.println("相等"); }else{ System.out.println("不相等"); } }}
運行效果:
asddsa不相等
題目2:
import java.util.Scanner; /** * 題目2:編程統計用戶從鍵盤輸入的字元串所包含的字母、數字、其他字元的個數 * @author Retror * */public class CountStr { public static int numCount; public static int strCount; public static int otherCount; public static void main(String[] args) { Scanner scan=new Scanner(System.in); String str=scan.nextLine(); char chs[]=str.toCharArray(); for(int i=0;i<chs.length;i++){ if(chs[i]<=57&&chs[i]>=48){ numCount++; }else if((chs[i]<=122&&chs[i]>=97)||(chs[i]<=90&&chs[i]>=65)){ strCount++; }else{ otherCount++; } } System.out.println("字母個數:"+numCount); System.out.println("數字個數:"+strCount); System.out.println("其他字元個數:"+otherCount); }}
運行效果:
123qqsda sdas字母個數:3數字個數:9其他字元個數:1
希望能幫到你,望點贊。
㈨ java基礎編程求完整代碼
1.利用循環解決問題前要考慮是否需要使用循環,如果說代碼非常容易展開的話可以考慮手動寫,在寫代碼的時候要避免寫不必要的循環,因為循環運行時沒有順序結構快。然後思考要用循環干什麼,遍歷數組?還是單純的使代碼多執行幾次?
2.這里給出三種實現方式
① for (int i = 100; i > 0; i -= 5) System.out.println(i);
② int i = 500;
while(i > 0) {
System.out.println(i);
i -= 5;
}
③ int i = 100;
do {
System.out.println(i);
i -= 5;
} while (i > 0);
流程圖:
① 一創建變數i = 100;
二判斷 i > 0,若是則進入循環,否則退出循環
三執行println
四執行i -= 5
五返回四
② 同①
③一創建變數i = 100
二執行println
三執行i -= 5
四判斷i > 0,若是則返回二,否則退出
3.int i= 1;
int c = 0;
do {
if (i % 7 == 0) c += i;
++i;
} while (i <= 50);
System.out.println(c);
㈩ Java基礎編程
import java.util.Scanner;
public class TestJava {
public static void main(String[] args){
System.out.print("Enter a Binary string: ");
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
//判斷輸入的格式
if(input.matches("[0|1]+")){
//輸出二進制到十回進制的答轉換
System.out.println(Long.parseLong(input,2));
}else{
System.out.println("Invalid Binary String "+input);
}
sc.close();
}
}