Crystal
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 資料型態與計算1 - 運算子 - `+` `-` `*` `/` `%` `==` `!=`以上運算子同C - `!`不:常用於布林值 - Java預設型態為為int - 這邊有一個常見問題(如果沒搞清楚型態與記憶體的關聯) - 無法印出多個變數直接運算超過範圍的值 - 印出來還是超出,扣除127會得到別的數字,這就是溢位 ![](https://i.imgur.com/QQqOTxM.png) - 解決方法:型態轉換(強轉) ```java= byte x=(byte)(y+z); //先乘除後加減 括號先做 ``` - 我們宣告的代號**對應**電腦看的記憶體位置,這就是Point(指標) ![](https://i.imgur.com/lZqHaG8.png) 計算的原理是丟到CPU運算再丟回來(?) - 移出method的方法 ![](https://i.imgur.com/5hHZmF6.png) - static靜態 ## 程式各個部分的命名原則 - class類別 - 首字母大寫,第2字首字母大寫 - 例:DemoCode - 不能用數字跟特殊符號,第二個數字以後可以 - 除非_xxx,這是類似標頭檔的概念 - 不能用關鍵字或保留字(編譯器高亮的字) - 最好不要用goto - 因為Java的底層是C - 名稱要有意義,以功能為名也可以 - package套件 - 把網域反轉,最後一個字為模組名稱 - 補充:網域反轉只是講師要讓人好理解的比喻,實際上是個巧合 關於package的命名原則可以看[這篇](https://segmentfault.com/a/1190000038245787) - 全部小寫 - 不能使用(他人用過的) - method函數、方法 - 首字母小寫,第2字首字母大寫 - 例:demoCode - 不能用數字跟特殊符號,第二個數字以後可以 - 不能用關鍵字或保留字(編譯器高亮的字) - 名稱要有意義,以功能為名也可以 - 變數同method ## class - 一個專案的基本單位 - 表個別功能 - 結構 - static靜態method - 當專案運行,只要有static都會先切割記憶體,反之一般只有呼叫時才會切割記憶體 - 有分配記憶體才能呼叫 - 直到專案關閉才會銷毀記憶體 - 一般method 寫法: ```java= public void getMethod(){ } ``` 跟靜態method相對,使用完一段時間後無人進行呼叫就進行銷毀記憶體 - 變數也有類似的概念 - 靜態變數`private static int x=數值;` - 一般變數`private int y;` ## main method - 一個專案只會有一個main method - 因為程式只會有一個進入點 - 傳入為String - Java認定傳入為String、輸出為String - String[]:字串陣列 - args String[]的名稱(=電腦中記憶體位置) - 靜態&文字池的示意圖![](https://i.imgur.com/hciw6ZN.png) ## long 宣告: ```java= long x=123L; ``` - L大小寫都行,但大寫比較易讀 運算: ```java= long a=123L; long b=456L; long c=a+b; ``` ## int - Java預設的型態之一(還有double),後方不用加字母 - 補充:基本上只有byte跟short需要型態轉換,畢竟太小了 一些現象: ```java= int a=10; long b=10L; a=b; //不能賦值(裝不下) ``` ```java=+ b=a; //可以賦值(裝得下) ``` ```java=+ y=(int)j; //沒有意義的寫法 ``` 備註:不同型態轉換要格外注意! - 一個優秀的程式設計師會 - 盡量節省記憶體 - 不寫廢程式碼

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully