手打的笔记:

() 内的则为注意事项或者提示

public static void main (String[] args) ******(用一个方法)****
{
int i = 10;

int j =20;

System.out.println(i == j);

与 并且关系:

System.out.println(true & true);

System.out.println(true & false);

System.out.println(false & true);

System.out.println(false & false);

System.out.println(i >0 && j>0);

或 或者关系:

System.out.println(true || true); (短路写法,只要前面对了,就都对了) (与并且相反)

非:

System.out.println(!(i < 0));

字节有八位

00000010

System.out.println(2 << 2); (00001000) 左移几位取决于后一位

3 2 = 12 3和2之间放什么符号 等式成立

左移运算规律:

x << y = x * 2的y次方

右移与左移相反

三元运算符:(不能单独存在,赋值或者输出)(可以套着写)

System.out.println(i>0 ? "i大于0" : "i小于等于0"); (类似if else 变形)

String str ="";

if(j>10)
{
str = "j大于10";
}
else
{
str = "j不大于10";
}

str = j >10 ? "j大于10" :"j不大于10";

System.out.println(str);

通过控制台手动输入:

System.in 输入流

System.out 输出流

Scanner sc =new Scanner(System.in); (实例化输入扫描器)

System.out.print("请输入名称:");

String strin = sc.nextLine(); (等待输入)

System.out.println("你输入的名称是:"+ strin); (输出接受的)

加法计算器: (其他的计算类型随意)

System.out.print("请输入第一个数字:");

long a =sc.nextLong();

System.out.print("请输入第二个数字:");

long b =sc.nextLong();

System.out.println(a+b);

分支语句:

int i =10;

if(i>0)
{
System.out.println("条件成立")
}
else
{
System.out.println("条件不成立")
}

if(i>0)System.out.println("i>0"); (简便写法)

if(i>0)
{
System.out.println("条件成立")
}
else if( i>5 )
{
System.out.println("条件不成立")
}

else

{

}

switch语句: (支持类型:int byte char short 枚举 字符串)

switch(i)

{

case1: (case后面必须为常量)

System.out.println("1");

break;

case2:

System.out.println("4");

break;

case3:

System.out.println("6");

break;

default:

System.out.println("123");
}

循环:

i=10;

while(i>0)
{
System.out.println("i ="+i);

i--;
}

do

{
System.out.println("i ="+i);

i--;

}

while(i>0);

for(i=0;i<10;i++)

{
System.out.println("i ="+i);

if(i==2)
{
continue; (跳过 执行后面的)
}

if(i==5)
{
break;
}
}

}

手打的笔记,java语法中的输入输出,语句,及注释。的更多相关文章

  1. java finally中含return语句

    <java核心技术卷一>中提到过:当finally子句包含return 语句时(当然在设计原则上是不允许在finally块中抛出异常或者 执行return语句的,我不明白为何java的设计 ...

  2. 关于在Java代码中写Sql语句需要注意的问题

    最近做程序,时不时需要自己去手动将sql语句直接写入到Java代码中,写入sql语句时,需要注意几个小问题. 先看我之前写的几句简单的sql语句,自以为没有问题,但是编译直接报错. String st ...

  3. [心得笔记]Java多线程中的内存模型

    一:现代计算机的高速缓存 在计算机组成原理中讲到,现代计算机为了匹配 计算机存储设备的读写速度 与  处理器运算速度,在CPU和内存设备之间加入了一个名为Cache的高速缓存设备来作为缓冲:将运算需要 ...

  4. [学习笔记]Java代码中各种类型变量的内存分配机制

    程序运行时,我们最好对数据保存到什么地方做到心中有数.特别要注意的是内存的分配.有六个地方都可以保存数据: (1) 寄存器 这是最快的保存区域,因为它位于和其他所有保存方式不同的地方:处理器内部.然而 ...

  5. [Java入门笔记] Java语言基础(一):注释、标识符与关键字

    注释 什么是注释? 注释是我们在编写代码时某段代码.某个方法.某个类的说明文字,方便大家对于代码的阅读.被注释的内容不会被编译.执行. Java的注释分为三种类型:单行注释.多行注释.文档注释. 单行 ...

  6. [java学习笔记]java语言基础概述之标识符&关键字&注释&常量和变量

    一.标识符 在程序中自定义的一些名称 由26个英文字母的大小写,数字,_$组成 定义合法标识符的规则: 不能以数字开头 不能使用关键字 java严格区分大小写 注意:在起名字时,为了提高阅读性,必须得 ...

  7. java try中包含return语句,finally中的return语句返回顺序

    //结论: finally 中的代码比 return 和 break 语句后执行 public static void main(String[] args) { int x=new Test.tes ...

  8. ansible_playbook语法中的循环语句归纳

    种类一.标准循环添加多个用户 - name: add several users user: name={{ item }} state=present groups=wheel with_items ...

  9. java web中使用mysql语句遇到的问题

    1.插入数据时遇到     Parameter index out of range (1 > number of parameters, which is 0).  的问题 有问题的代码: 改 ...

随机推荐

  1. eclipse 搭建Swt 环境

    我本是想用java开发一个记事本,开发记事本使用到SWT插件,我从网上找了许多的资料去集成插件,创建我的第一个SWT项目,以下是我搭建SWT环境的过程. 一.查看当前使用的exlipse 版本型号 在 ...

  2. beanstalkd----安装启动

    1. 安装This is beanstalkd, a fast, general-purpose work queue.See http://kr.github.io/beanstalkd/ for ...

  3. JS-数组的方法

    var arr = [ 1,2,3 ];arr.push( 'abc' );//从后面加 arr.unshift( 0 );//从前面加 arr.pop()//从后面删除 arr.shift()//从 ...

  4. 【fortify】安全漏洞的分类

    https://vulncat.hpefod.com/zh-cn 下面摘要著名的软件安全专家Gary Mc Graw的2006年的新书<Software Security building se ...

  5. a questions

    1.2520 is the smallest nuber that can be diveded by each of the number from 1 to 10 without any rema ...

  6. bdb log为什么 有 region buffer 和 log cursor buf

    对bdb log来说, 在共享内存中 有一块 buffer, 同时每一个 log cursor 都自带一个 malloc的buf. why? 我认为: region buffer存的是log最末尾, ...

  7. poj 2142 拓展欧几里得

    #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> ...

  8. ProceedingJoinPoint获取当前方法

    aspectJ切面通过ProceedingJoinPoint想要获取当前执行的方法: 错误方法: Signature s = pjp.getSignature();     MethodSignatu ...

  9. sql 动态语句

    如果动态语句有表变量 例子如下: declare @mS varchar(10) declare @mE varchar(10) declare @mSQL nvarchar(500) --SQL语句 ...

  10. Eclipse - Failed to load the JNI shared Library (JDK)

    When I try opening Eclipse, a pop-up dialog states: Failed to load the JNI shared library "C:/J ...