- 浏览: 1051181 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (1355)
- test (75)
- 红茶和绿茶 (1)
- Jave SE (206)
- Oracle (19)
- English (177)
- Log4j (5)
- RIA(Rich Internet Applications) (9)
- Ext Js (6)
- Android (14)
- Logo (0)
- 文字采撷 (287)
- 使用技巧 (92)
- Project Management (22)
- Hibernate (12)
- Struts (5)
- 规则引擎 (1)
- Html & Javasctipt (56)
- Spring MVC (10)
- Maven (17)
- Java Test (17)
- Linux (16)
- Tools (1)
- CV (0)
- Middleware (2)
- HTML5 (2)
- Algorithms (4)
- Web Service (15)
- 留学 (15)
- LADP (5)
- PXCOA (0)
- SysLog (6)
- SSO (3)
- Spring Security (4)
- Spring Batch (1)
- Jmail (1)
- Bible (4)
- Java Thread (5)
- Architect (6)
- github (2)
- Java Swing (12)
- NoSQL (7)
- UML (2)
- 敏捷(Agile) (7)
- Hudson+Maven+SVN (15)
- cloud computing (2)
- Bahasa Indonesia (1)
- jBPM (6)
- 民俗知识 (3)
- Consulting (1)
- Mysql (5)
- SAP (1)
- 微信公众平台接口开发 (3)
- 做生意 (1)
- 西餐 (1)
- Banking (1)
- Flex (0)
- 黄金投资 (1)
- Apache Tomcat 集群 (3)
- Hadoop (7)
- 需求分析 (1)
- 银行知识 (3)
- 产品管理 (2)
- 钢琴Music (3)
- 设计 (3)
- Marketing (2)
- US Life (3)
- 算法 (14)
- BigData (4)
- test红茶和绿茶Jave SEOracleEnglishLog4jRIA(Rich Internet Applications)Ext JsAndroidLogo文字采撷 (0)
- Design Pattern (5)
- NodeJS&AngularJS (9)
- Python (1)
- Spring boot (0)
- ACM (3)
最新评论
-
心往圣城:
微时代-最专业的微信第三方平台。LBS定位导航,微网站,自定义 ...
微信公众平台 /微信公众平台怎么用 -
zhaojiafan:
return ReverseStr1(str.substrin ...
逆转字符串 Write a String Reverser (and use Recursion!) -
zhaojiafan:
public class StringUtils {
p ...
逆转字符串 Write a String Reverser (and use Recursion!)
Some Java programs which help lot of java beginners to understand the basic fundamentals in Java programming.
Program 1
//Find Maximum of 2 nos.
class Maxof2{
public static void main(String args[]){
//taking value as command line argument.
//Converting String format to Integer value
int i = Integer.parseInt(args[0]);
int j = Integer.parseInt(args[1]);
if(i > j)
System.out.println(i+" is greater than "+j);
else
System.out.println(j+" is greater than "+i);
}
}
Program 2
//Find Minimum of 2 nos. using conditional operator
class Minof2{
public static void main(String args[]){
//taking value as command line argument.
//Converting String format to Integer value
int i = Integer.parseInt(args[0]);
int j = Integer.parseInt(args[1]);
int result = (i<j)?i:j;
System.out.println(result+" is a minimum value");
}
}
Program 3
/* Write a program that will read a float type value from the keyboard and print the following output.
->Small Integer not less than the number.
->Given Number.
->Largest Integer not greater than the number.
*/
class ValueFormat{
public static void main(String args[]){
double i = 34.32; //given number
System.out.println("Small Integer not greater than the number : "+Math.ceil(i));
System.out.println("Given Number : "+i);
System.out.println("Largest Integer not greater than the number : "+Math.floor(i));
}
Program 4
/*Write a program to generate 5 Random nos. between 1 to 100, and it
should not follow with decimal point.
*/
class RandomDemo{
public static void main(String args[]){
for(int i=1;i<=5;i++){
System.out.println((int)(Math.random()*100));
}
}
}
Program 5
/* Write a program to display a greet message according to
Marks obtained by student.
*/
class SwitchDemo{
public static void main(String args[]){
int marks = Integer.parseInt(args[0]); //take marks as command line argument.
switch(marks/10){
case 10:
case 9:
case 8:
System.out.println("Excellent");
break;
case 7:
System.out.println("Very Good");
break;
case 6:
System.out.println("Good");
break;
case 5:
System.out.println("Work Hard");
break;
case 4:
System.out.println("Poor");
break;
case 3:
case 2:
case 1:
case 0:
System.out.println("Very Poor");
break;
default:
System.out.println("Invalid value Entered");
}
}
}
Program 6
/*Write a program to find SUM AND PRODUCT of a given Digit. */
class Sum_Product_ofDigit{
public static void main(String args[]){
int num = Integer.parseInt(args[0]); //taking value as command line argument.
int temp = num,result=0;
//Logic for sum of digit
while(temp>0){
result = result + temp;
temp--;
}
System.out.println("Sum of Digit for "+num+" is : "+result);
//Logic for product of digit
temp = num;
result = 1;
while(temp > 0){
result = result * temp;
temp--;
}
System.out.println("Product of Digit for "+num+" is : "+result);
}
}
Program 7
/*Write a program to Find Factorial of Given no. */
class Factorial{
public static void main(String args[]){
int num = Integer.parseInt(args[0]); //take argument as command line
int result = 1;
while(num>0){
result = result * num;
num--;
}
System.out.println("Factorial of Given no. is : "+result);
}
}
Program 8
/*Write a program to Reverse a given no. */
class Reverse{
public static void main(String args[]){
int num = Integer.parseInt(args[0]); //take argument as command line
int remainder, result=0;
while(num>0){
remainder = num%10;
result = result * 10 + remainder;
num = num/10;
}
System.out.println("Reverse number is : "+result);
}
}
Program 9
/*Write a program to find Fibonacci series of a given no.
Example :
Input - 8
Output - 1 1 2 3 5 8 13 21
*/
class Fibonacci{
public static void main(String args[]){
int num = Integer.parseInt(args[0]); //taking no. as command line argument.
System.out.println("*****Fibonacci Series*****");
int f1, f2=0, f3=1;
for(int i=1;i<=num;i++){
System.out.print(" "+f3+" ");
f1 = f2;
f2 = f3;
f3 = f1 + f2;
}
}
}
Program 10
/* Write a program to find sum of all integers greater than 100 and
less than 200 that are divisible by 7 */
class SumOfDigit{
public static void main(String args[]){
int result=0;
for(int i=100;i<=200;i++){
if(i%7==0)
result+=i;
}
System.out.println("Output of Program is : "+result);
}
}
http://www.freejavaguide.com/javasource1.htm
发表评论
-
各种在线工具
2018-05-10 05:52 412http://rextester.com/ -
Java Array sort and Collections sort
2018-04-11 04:55 385package com.test; imp ... -
webpack+es6+node+react初实践及总结
2018-02-01 10:38 362webpack+es6+node+react初实践及总结 ... -
Interview Preparation
2018-01-25 08:26 438Algorithms https://www. ... -
深入理解Java集合框架
2017-08-18 08:40 622https://github.com/CarpenterLe ... -
logic gate (AND, OR, XOR, NOT, NAND, NOR and XNOR)
2017-08-18 08:33 2454A logic gate is an elementary ... -
深入理解Java PriorityQueue
2017-08-18 01:25 420本文github地址 Java中PriorityQueu ... -
jwt-spring-security-demo
2017-08-12 07:30 609https://github.com/szerh ... -
Java Program to Check Whether a Number is Palindrome or Not
2017-08-08 06:59 548public class Palindrome { ... -
Java实现Tire
2017-08-07 08:14 597Java实现Tire Trie ... -
OpenID, SAML, and OAuth
2017-08-03 07:03 594Single sign-on (SSO) started i ... -
分享两个JavaEE 非常好的网站,案例丰富
2017-08-01 09:07 349http://www.mkyong.com/al ... -
Introduction to Programming in Java
2017-07-19 13:26 459http://introcs.cs.princeton.ed ... -
Two piece of code
2017-06-20 00:43 430if ( updateRe ... -
ACM Online Judge
2017-06-05 01:26 455http://acm.nyist. ... -
java枚举使用详解
2017-05-25 06:16 465package com.ljq.test; /** ... -
Longest Common Substring
2017-05-21 08:22 505Dynamic Programming | Set 29 ( ... -
Dynamic Programming
2017-05-06 10:48 366Dynamic Programming | Set 1 (O ... -
Predefined Character Classes
2017-04-24 02:45 402Predefined Character Clas ... -
IS-A Relationship And HAS-A Relationship
2017-04-13 14:50 1703One of the advantages of an Ob ...
相关推荐
course because Sun provides a sufficient set for free. Fundamentals of the JavaMail API Page 3 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 3. ...
Preface....................................................................................................................................... 14 1 Introduction ..........................................
An easy-to-follow, example-based guide that will walk you through the core principles of concurrency and multithreading using C#. Table of Contents Chapter 1. Traditional Concurrency Chapter 2. Lock-...
IT pros and power users consider the free Windows Sysinternals tools indispensable for diagnosing, troubleshooting, and deeply understanding the Windows platform. In this extensively updated guide, ...
Learn how to write bug-free programs Turn tedious common tasks into quick and easy ones Use minimal code to work with JSON, CSV, XML, and HTML data Integrate F# with your existing C# and VB.NET ...
Mastering C# Concurrency Create robust and scalable applications along...An easy-to-follow, example-based guide that will walk you through the core principles of concurrency and multithreading using C#.
He is currently the maintainer of several critical kernel subsystems, including USB, PCI, I2C, driver core, and sysfs. Additionally, he maintains the udev and hotplug userspace programs and ...
"C Programming for Scientists and Engineers" is a comprehensive guide tailored for students and professionals in the fields of engineering and science. It provides a solid foundation in C programming,...
- Disk space: 6 Meg of free hard disk space (plus an additional 10Meg to run the Disk test) - DirectX 9.0c or above software for 3D graphics and video tests (plus working DirectX drivers for your ...
During the Core elections in 2002, Mark Murray stated “I am opposed to a long rule-book, as that satisfies lawyer-tendencies, and is counter to the technocentricity that the project so badly needs.”...
Free software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Contributors to GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
CanFestival is released under the LGPL (Lesser General Public License), allowing free use, modification, and distribution of the software while preserving the rights of the original authors and ...
for more about it please read user's guide file. 1.how to build tar jxvf SimIt-ARM-3.0-gk-20150902.tar.bz2 cd SimIt-ARM-3.0-gk ./configure make make install After these steps, the ./build/...
Embedded: You can use RaptorDB inside your application as you would any other DLL, and you don't need to install services or run external programs. NoSQL: A grass roots movement to replace relational...