各类编程语言的Hello World写法

(每隔一段时间整理几门语言的HelloWorld写法,更新中......)

A开头:
        1、Android(版本4.2.2)
          Activity:
          package com.javagoboy.helloworld;

          import android.os.Bundle;
          import android.app.Activity;
          import android.view.Menu;

          public class HelloWorld extends Activity {

                    @Override           
                    protected void onCreate(Bundle savedInstanceState) {
                           super.onCreate(savedInstanceState);
                           setContentView(R.layout.activity_hello_world);
                    }
 
                    @Override
                    public boolean onCreateOptionsMenu(Menu menu) {
                           getMenuInflater().inflate(R.menu.hello_world, menu);
                           return true;
                    }
           }
          Activity配置:
          <activity
            android:name="com.javagoboy.helloworld.HelloWorld"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>               
        启动应用:
             
B开头:
C开头:
         
1、C
               vi helloworld.c

               #include<stdio.h>
 
               int main(void) {
                     printf("Hello,World!\n");
                     return 0;
               }
               在Linux环境下执行:
               使用gcc编译:gcc helloworld.c -o helloworld
                            执行:./helloworld

          2、C++
              vi helloworld.cpp

               #include <stdio.h>
               #include <iostream>

               int main() {

                      puts("Hello,World!");
                      std::cout << "Hello,World!" << std::endl;

                      return 0;
                }
                编译:# g++ helloworld.cpp -o helloworld
                执行:# ./helloworld

D开头:
E开头:
F开头:
G开头:

         1、Go语言

 

               package main

               import (

                     "fmt"

               )

               func main() {

                      fmt.Println("Hello World !");

               }

               保存为:helloworld.go

               执行:go run helloworld.go


H开头:
I开头:
J开头:
        
1、Java

 

               public class HelloWorld {

                         public static void main(String[] args) {

                                System.out.println("Hello,World !");

                         }

               }

               保存为:HelloWorld.java

               编译:javac HelloWorld.java

               执行:java HelloWorld
 

            2、JavaScript(ECMAScript派生语言 )

 

               <html>

                    <title>Hello World</title>

                <body>

                    <script type="text/javascript">

                         document.write("Hello World !");

                         alert("Hello World !");

                    </script>

                </body>

               </html>


K开头:
L开头:
M开头:
N开头:
O开头:
P开头:
       
  1、Python(版本3.3.2)

 

               命令行:print("Hello World");


Q开头:
R开头:
S开头:
         
1、sh(Shell脚本)

 

               新建一个.sh文件: vi helloworld.sh

               在helloworld.sh中输入:

               #!/bin/sh

               a="Hello World !"

               echo $a

 

               修改helloworld.sh为可执行文件:chmod +x helloworld.sh

               执行 ./helloworld.sh

T开头:
U开头:
V开头:
W开头:
X开头:
Y开头:
Z开头

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值