Programming Shortcut

Write, Run and execute Your programs with simple and esay way by Programming Shortcut

Showing posts with label Programs in java. Show all posts
Showing posts with label Programs in java. Show all posts

Monday, July 29, 2019

Difference and similarities between java and c++

There are many differences and similarities between java and c++ and the following below discuss briefly in by the table one to one comparison into differences and similarities between java and c++

Features in JAVA in C++/CPP
Data abstraction and encapsulation
Polymorphism
Binding Static
Dynamic
Inheritance Single Inheritance
Multiple Inheritance
Operator overloading
Template classes
Global variables
Header files
Pointers
Interface and packages
API (Application Programming Interface)

Java and C++ or CPP are both object oriented programming language but may have different feature and work and use of the application. 
inheritance here is a bit difference between C++ and java. C++ supports are both single as well as multiple, multiple is a very complex inheritance mechanism. On the other hand, does not support multiple inheritances, supports only single inheritance. And, then operator overloading this is another important things; that means, that different operator, for example, the CPP can be used for adding two numbers, plus can be used for adding two documents like this is a polymer print concept actually.

Operator overloading is a concept of polymorphism. C++ allows operator overloading whereas, Java does not allow operator overloading. And, then template classes these basically C++ allow template class; that means, one template means is basic class can be developed which basically not suitable for creating an object, but it is a template only. But Java does not give any facilities to create a template class. There are few more things like a pointer is possible pointer is not possible in Java whereas, the pointer is possible in C++. And, interface and packages Java is a very good one features regarding this whereas, in C++, does not have.


More Code »

Function Oriented Programming and Object-Oriented Programming


What is the difference between in the Function Oriented Programming and then Object-Oriented Programming :

In the Function Oriented Programming and then Object-Oriented Programming and obviously, there are many good points and bad points of both programmings,
I have listed a brief summary of the different facilities that the Functionality Programming and then Object Oriented Programming provide us.


Function Oriented Programming:-


Programming Organization: Program is divided into small parts called functions.
Importance: Importance is not given to data but to functions.
Approach: Function Oriented Programming follows a top-down approach.
Access Specifiers: Function Oriented Programming dose not any access specifier.
Data Moving: Data can move freely from function to function in the system.
Maintainability: To add new data and function is not easy.
Data Access: function uses global data for sharing that can be accessed freely from function to function freely in the system.
Data Hiding: No data hiding is possible, hence security is not possible.
Overloading: Polymorphism is not possible.
Examples: C, Visual Basic, FORTRAN, Pascal.
 

Object-Oriented Programming:- 

Programming Organization: Program is divided into parts called objects.
Importance: Importance is given to the data rather than procedures.
Approach: Object-oriented programming follows a bottom-up approach.
Access Specifiers: Has three access specifiers, namely:- Public, Private, Protected.
Data Moving: Object can move and communicate with each other.
Maintainability: Provides an easy way to add new data and function.
Data Access: Object uses local data and can be accessed in a controlled manner.
Data Hiding: Provides data hiding, hence secured programming is possible.
Overloading: Ploymarphism is possible.
Exmaples: C++, JAVA, VB.NET, C#.NET.

More Code »

Wednesday, May 29, 2019

How to set path in java in windows 10, 8.1, 8, 7

If you have decided to learn an object oriented programming language like Java, you might be excited and want to start right away. In this article, I will show you how to make your first simple program and run it on your computer.

You need 3 things:

A compiler
A good self-study book or a course
Persistence
There are three editions of Java. SE, ME and EE. You want the SE which is Standard Edition. The others are Mobile Edition and Enterprise Edition.

After you have downloaded and installed the JDK, you need to make one small change in your PC settings. You want the compiler to be accessible from the command prompt.

To do that you have to add the location of the program files to the PATH variable.

1: Click Start → Control Panel → System ( assuming you use Windows 10)

2: Click Advanced → Environment Variables.

3: Find the location of the bin folder in your installation. You can do this by using the Explorer. It's a good idea to copy the path from there. It might be: "C:ProgramsJavajdk1.6.0_23bin"

4: Add the location to the PATH variable. You probably already have a PATH variable, so choose Edit for that one add a semicolon in the end and the location you copied in step 3

You can test if it is working by opening a command prompt and type JAVAC. This should make the compiler run. Since you did not give a file name as parameter, it just shows you the help file.

Now that you have the compiler working, it is time to make your first Java application. Open notepad or any other simple text editor and type in the following text exactly like shown here.

public class HelloWorld
{public static void main (String [] args)
{System.out.println ("Hello World!");}}

Then save the file as "HelloWorld.java" in the folder where you want to keep your Java projects. Make sure you don't save it with the.txt extension, even thou it is a text-only file.

Go back to your command prompt and type:

javac HelloWorld.java

This will tell the Java compiler to translate the file you just made. If there is no errors you will now have a file called "HelloWorld.class". This is the byte code version of your program. It cannot be run as you would do with an executable program file. Instead you need the Java interpreter. You can test your program with the
command:

java Helloworld

Note that you don't need the.class extension. You should now get the output from your program:

Hello World!

Congratulations! You have now made and tested your first Java program. I recommend you also try to make a small change, to get a feel of how things work. Of course it is difficult now, as most of the code don't make much sense when you don't know Java yet. But you can change the text between the quotation marks to make the program print a different text.

More Code »

Object-Oriented Programming (OOP) in Java

What is Object Oriented Programming?

Object-Oriented Programming is a programming process, That process work on the principle
of class and object. Object-Oriented Programming is provided a structural way programming techniques that work is optimized code and time effort and increase code re-usability of your programming.

In the Java oops concepts use following :

1.Object
2.Class
3.Inheritance
4.Polymorphism
5.Abstraction
6.Encapsulation

What is Object?

 An object is a real-world entity like a book, table, chair etc. In the term of programming, the object is
 is a method, a function, an entity of the class.
 What is a class?
 A class is set a set of Object or collection of the object and also class is a blueprint of all method(Object).

 Example: A book is a class then there book common object is "book={ title, book_type, page_no, author } ".
Here title is what the title is of the book, book_type What type of book is like Novel, biography or textbook(in math, science, English, programming), page_no is how many page no in the book, and an author is who writes the book.

 public class book{  // Main Class of java programming
String title;
String book_type;
int page_no;
String auther;
public static void main(String[], args){  // Main Function of java programming
book b=new book();
b.title=Java: The Complete Reference;
b.book_type =textbook;
b.page_no=1344 ;
b.auther=Herbert Schildt
System.out.print(b.title);
System.out.print(" is a "+b.book_type);
System.out.print(" it has "+b.page_no+" pages ");
System.out.print(" and it the author is "+b.auther);
}
 }

 Output: The Complete Reference is a textbook it has 1344 pages and it the author is Herbert Schildt

What is Inheritance in Java?

 Inheritance means Inherited property one to other. In Programming term Inheritance is extend a class property(like instance, function or method) to the other class.From which class inherit their property this is called base class or parent class and what inherit from a base is called child class or dived class.

What is Polymorphism in Java?

Polymorphism is a way in oops in java that can work one action in many Ways to draw a shape but draw a Shape like many ways to draw a rectangle, draw a circle draw a triangle, and draw a square shape etc.

What is Abstraction in Java?

Abstraction is a method that can hide methods or instance and show the process only access granted user. Abstraction is used to secure confidential information for security region.
For example, a program has many functions or methods that can use it everywhere that they want but require some functions or methods used in particular section, so use Abstraction to hide these functions or methods to use in the particular area or section.

What is Encapsulation in Java?

Encapsulation is method by this method we use a private or procreated method in a public method.

What is the advantage of OOPs concept java?

There are many advantages of oops concept of java, these are following:-
1. By OOPs methods managing programming structure easy and well-documented program.
2. OOPs, methods increase code re-usability. it means we can oops method make an object and use the same code with different parameter and input for different propose.
3. OOPs, methods are easy to use and modify programs.
4. OOPs, methods decrease complexity and optimized programs.
5. OOP,s methods provoid level by level security by abstraction.
6. OOP,s methods program easy to upgrade in future.
7. Mantaince is easy in the object-oriented programming.

Thanks, friends
To read this post I hope that you will like the post, Please rate my work for increase my confidence.
Please share this post also if find helpful to other.
Also you can

object oriented programming examples
object oriented programming concepts
object oriented programming languages
object oriented programming principles
object oriented programming paradigm
features of object oriented programming

Have a nice day, take care.

More Code »

Monday, April 29, 2019

Difference Between Java and Dot NET

The purpose of writing this article is to provide a layman term of explaining the similarities and difference between Java and .NET. I always have students asking me the difference between each of them and whenever I answered their question, they still have doubts due to the lack of fundamental understanding between each of them.

So before we start comparing them, we must first understand their definition. What are they? What do they do? Who developed them? What do they contain and etc?

Java

Java is an open source implementation of the Java Platform, developed by Sun Microsystem (bought over by Oracle). Its Java programming language is a lightweight programming language that can be run on any operating systems such as UNIX, Linux, Windows and etc. with the help of JVM (Java Virtual Machine). Source programs that are written in Java, is first compiled to machine independent code, called bytecode. During run time, the virtual machine reads the bytecode and executes it by translating it to target machine instructions for the operating system.

.NET

.NET is a software framework developed by Microsoft. It runs primarily on Microsoft Windows Operating System. The .NET framework consists of two key components: .NET Framework Class Library, and Common Language Runtime (CLR). The .NET Framework Class library has a collection of programming languages that are capable of developing different types of software applications such as desktop, server, and mobile applications. These include support for simple data types, I/O functionalities, database support, Graphical User Interfaces (GUIs) and etc. Common Language Runtime provides support for Microsoft Intermediate Language (MSIL) code execution, by providing features such as code checking and compilation.

After having a basic understanding of each of them, I will be providing a comparison between them. I will first compare them based on their similarity, then follow by their difference in terms of developing different types of software application such as desktop, web and mobile applications.

Similarities

Both are capable of developing quality and high-end application software.
Both have programming languages that serve different types of software application needs.
Both have a collection of APIs for development purposes.

Differences in Desktop Application Development

Java AWT (Abstract Window Toolkit) and Swing Library are used to develop Java Desktop Application. To develop a more interactive Desktop Application like Adobe Flash, developers may use JavaFX.
.NET has a popular desktop development platform that uses the Windows Forms, Windows Presentation Foundation, and Silverlight.
Both platforms, Java and.NET provides drag and drop features for implementing a desktop application in their Integrated Development Environment (IDE)

Differences in Web Application Development

Competition between the use of Java Enterprise Edition and Microsoft ASP.NET in developing dynamic web application software.
JEE mainly uses Apache Tomcat as their application server and Microsoft ASP.NET uses Internet Information Services (IIS).

The difference in Mobile Application Development

Competition between Java Mobile Edition (Java ME) and.NET Compact Framework.
More Code »

How to Write a Simple Java Program

 Java is an object-oriented language similar to C++. But it is designed to be simplified to eliminate the possibility of creating common programming errors, such as memory corruption, pointer or reference errors.

Before you start to write a Java program, you have to select your development environment:

Use Java Software Development Kit (SDK) and a text editor, such as Notepad, EditPlus.
Use an Integrated Development Environment (IDE), such as NetBeans, Eclipse.
Now let's see source code of the simplest Java program which simply displays a message to the console window:

Source Code
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}

How run the java program ?

If you're using a text editor, you have to named the file as same as class name which is 'HelloWorld', with the extension.java appended. Then, compile the file by run this command:
$javac HelloWorld.java

After you've compiled the file, the Java compiler creates a bytecode file 'HelloWorld.class' from the source code. This file will be used to run by the Java interpreter. To run this, type this command:
$java HelloWorld

You will see output on console window:

Hello World!

If you're using an IDE, you can run this source code by click on Start Debugging. The IDE will compile, run source code and display an output as above.

Code explanation:

You have successfully written your first Java program. Now let's look at this source code line by line:

public class HelloWorld
Everything in Java must be inside a class. This class is called 'HelloWorld'. The keyword public is an access modifier which determine access level other classes can use this code. In this case, this class is visible to all classes everywhere.
public static void main(String[] args)
This is the only method in this class, main method, with a parameter args as array of String. Every Java program must have a main method. The static method is method that does not operate on an object so the main method has to be static because there aren't any objects when a program starts. The keyword void is used on a method indicates that the method returns no data.
System.out.println("Hello World!");
Here is the body of the main method. This class has only one statement, each statement is separated by a semi-colon (;). This statement, I use System.out object and call println method. The println method displays the text from parameter on console window and terminates the line.
More Code »

Thursday, April 18, 2019

What Are the Benefits of Java Programming?


Java is an object-oriented programming language. It is used in a variety of computing platforms, you can see it nearly everywhere nowadays, from embedded devices and mobile phones to enterprise servers and supercomputers. In the point of view of many IT experts, Java is a hot property of Sun Microsystem. Seriously speaking, JAVA has brought a lot of advantages to the software developers.

Is Java really great? Here are 7 good points to support.

1. It is simple.

This particular program is specially designed to be very user-friendly. If compared with other programming languages, Java is easier to write, compile, debug and learn. This is because it uses automatic memory management and garbage collection. New learners can apply it easily within a short period of time.

2. It is platform-independent

The best thing about Java is its ability to move easily from one computer system to another without creating any problem. "Write once, run anywhere" best describes Java. It can run independently at both the source and binary levels. The same program can be run smoothly on different systems. This special feature is extremely essential to World Wide Web software which needs a lot of flexibility.

3. It is secure

If security is your main concern, Java will be your best choice. It places security as its top priority. Its language, compiler, interpreter and runtime environment are customized with security in mind. Its platform allows users to download unknown code over a network and run it in a secure environment without causing harm to the systems. The host system will not be infected by virus at all. This capability alone has made the Java platform unique.

4. It is reliable

Honestly speaking, it is indeed hard to look for programming languages which are truly robust. However, Java has put a lot of effort on early checking for possible errors. Java compilers are able to detect many problems at the initial stage of execution. Hence, it is considered the most reliable programming by the developers.

5. It can perform multiple tasks 

Java has the capability to perform several tasks simultaneously. Multithreaded programming has been smoothly integrated into it. It works best in visual and network programming. At the same time, its stable standards help the developers to create multilevel applications with a component based approach.

6. It is dynamic

Java code is organized in modular object-oriented units. These units are known as classes. They are stored in separate files and are loaded into the Java interpreter only when required. In this situation, a program is able to extend itself dynamically by loading which classes it needs to expand its functionality.

7. It is economical 

How much do you need to invest on Java programming? It is an open source. Hence, you don't need to struggle with heavy license fees annually.

More Code »

Introduction of Java Programming Language


Java is a programming language developed by Sun Microsystems in 1995. It is designed to be platform independent. This means that the same program can run regardless of whether you use Windows, MacOS, Linux or a cell phone. To do this there must be a Java interpreter installed on the system where the program should run.
Java allows you to write programs without having to go out and buy something. It only requires some time and patience.
Java can be used for making interactive parts of web sites. It is known as applets. This may be small games or useful tools. Java should not be confused with JavaScript, which can also be used for websites. These are two different things.
Java games are used on many pages and are usually developed by professional programmers. It is also be possible to make a simple game if you are a hobby programmer. When I taught myself Java for a few years ago I made a little Java game to gain some practice in programming.
In this virtual world of an Internet Marketing, windfall profits have made the Java one of the fastest-growing and most extensively used programming language.

"Java" generally refers to a combination of three things:

Java programming language: It is a high-level, object-oriented programming language. Java is centered on creating & manipulating objects, and making the objects to work together.
Java Virtual Machine: Short for JVM, it is a high-performance virtual machine that executes byte codes on a specific computing platform.
Java platform: A JVM running compiled Java byte codes, usually calling on a set of standard libraries such as those provided by Java Standard Edition or Enterprise Edition . Though coupled by design, the language does not imply the JVM, and vice versa.

Java is a revolutionary language and so, for this reason, it is the most accepted computing language in use today for a wide-ranging purpose. Some of the substantial benefits of Java Programming language are:
Java is Architectural Neutral: Since Java's applications are typically piled-up to a byte-code and as its' integration is done into all the major operating system, so, for this reason, Java Program can be accessed on any platform with a Java Virtual Machine. Hence, one of the most compelling reason that persuade anyone to Java is its Portability, i.e. - Platform Independence and so developers will be just requiring for the writing of one version and that one version will be running on all the platforms without having to be recompiled. Java runs on most major hardware and software platforms, counting Windows 95 and NT, the Macintosh, and several varieties of UNIX as well.
Security: Language and platform were devised by maintaining the issue of security in mind. All browsers, whether it is a compiler, interpreter or Java-compatible, all hold a number of security measures. They are intended to diminish the risk of security compromise, loss of data and program integrity, and damage to system users. The Java platform allows a user to download an untrusted code over a network and run it in a secure environment as it will protect the host system to not to get infected with a virus.
Programmer Efficiency and Time-to-Market: The final and perhaps the most significant cause for taking the Java into a use is that it is well-liked by the programmers because with Java, they entertain a quick results and it makes their efficiency increase to the great extent. As Java is a simple and elegant language with a well-designed, intuitive set of APIs, programmers are able to write better code that too without shelling-out embarrassing amount of money. This thing reduces the development time.
Hence for these considerable benefits, Java is chosen as the programming language for the network computers (NC) and has been perceived as a universal front end for the enterprise database.

More Code »

Wednesday, April 17, 2019

How to start learning first programming language

Introduction

When we start to learn your first programming language, we have many questions like how to start your first programming language and what we need to start your programming language and what language is better to start. Programming is a very useful and rewarding hobby. There are few better feelings than when someone sees you using a program you lashed together to make your life easier and says that it looks really useful. Most people have, at some point in their lives, really wanted to be able to do something on their computer or phone and been unable to. If you know a programming language, then there is often a fair chance that you can write a program to accomplish that task yourself. While there are a huge number of programming languages, many of them have a lot of similarities; this means that once you learn one language quite well, in most cases you will be able to pick up a new one far quicker.

Selecting Your First Language

Now that we have examined the limitations and handled some of the more unrealistic expectations, those of you still wanting to learn to code will be happy to know that programming is not a hard thing to start learning and will not require you to pay out huge sums of money. If you are reading this article online, you already have the resources to start with some languages, so let us consider what your first language ought to be.

Traditionally the first language a programming newcomer learns is either Visual Basic or Python. The first thing to understand is that these two languages are very different. The simplest difference is one of price. Python is totally free; you can start writing python now with just a text editor on your computer, though if you are on Windows, you will probably need to install it first. However, Visual Basic, often abbreviated to VB, is both free and not free. On the upside, VB can be simpler for newcomers to learn because it allows you to build the interfaces (the part of the program the user will see) by dragging and dropping the different parts much like designing it in some basic art application. The version of VB newcomers learn is usually Visual Basic 6, but this is rather outdated and has been discontinued. So these days the version learned is often VB.NET which can be considerably less simple for newcomers.

VB.NET must be developed inside what we call an IDE (Integrated Development Environment); this is basically a special program you use to write other programs. They also exist for Python, but their use is totally optional. The free VB.NET IDE is called Visual Studio Express. At the time of writing, the latest version is Visual Studio Express 2010. Unfortunately, by using the free version of the IDE you are restricted with what you can do, and any programs you create cannot be commercially sold on. Regretfully, the full paid version of the IDE is not cheap, and probably not appropriate for a hobbyist, but fortunately, to learn VB the free version is enough. In practice, very few commercial programs are developed in VB these days, but the Visual Studio IDE allows you to use many other languages. The familiarity you will develop by using it will also allow you to use the power of the IDE for development in many other languages. Some will argue that almost every language can be developed in a text editor and that they are by far the most flexible way in which to code. While this is technically true (and I do suggest trying development in a text editor to compare once you get a little better), I would strongly advise learning your first language with a proper IDE.

While traditionally, people learn Python or VB first and these are generally what is taught at schools, I would not suggest either of these. I am of the opinion that your first language should continue to be useful to you one it has served the purpose of helping you learn the fundamentals of programming. If I had to recommend one of these for newcomers, it would be VB.NET as often the most complex part of programming is the graphical side of things and in VB.NET this is very simple due to the drag and drop interface. These two languages are often used as introductions as they are very tolerant of mistakes, and allow you to become confident in programming principles without worrying about a lot of the more complex matters.

For those brave souls among you, I would actually suggest Java as your first language, even though it can be complex, and is therefore not a common choice for a first language. Java programs are different from most others in that they do not run on your computer. The user downloads Java, then your code runs on what is called a VM (Virtual Machine). This means that your code runs in a special place Java sets up for it - a fake copy of your computer - and handles the translation of this to the real machine for you. This means that Java programs are "cross-platform", meaning that they will, for the most part, run on Windows, Mac, Linux, and most other operating systems.

Java is a good language to learn, as it is very widespread and useful. Furthermore, it is very powerful and is available for free for both hobbyists and commercial uses. However, in contrast to VB and Python, it does not tolerate mistakes and requires you to be very specific about everything. It is also an object-oriented programming language, which is a very complex issue which I will briefly try to summarise. Languages like Python and VB are what is known as procedural languages, meaning that the lines of code are run one after another, whereas Java is an object-oriented language. object-oriented development is a term thrown around a lot these days in the programming world, and while not always appropriate it is generally considered a good idea. At the most basic level, an object-oriented program is all about objects. An object is an "instantiation" of a "class". A class is a blueprint used to describe something like a cat. The class contains both the data about the cat such as its name, age and owner as well as "methods" which are essentially actions the cat can perform, such as miaow. An instance of the class "cat" would give you a particular cat. However, this is not a Java tutorial, so if you are brave enough to experiment with Java you will come across this yourself in more detail. It is worth noting that VB.NET and Python both have support for object-oriented development, and Java has the potential to be used procedurally, but these are not the languages' primary intended uses and are not often used. If you did not understand that comparison, don't worry about it too much. Object orientation is hard to get your head around, but any basic Java or another object-oriented language tutorial will have you understanding everything in that paragraph.

A final reason Java is a good first language is that it is similar in many ways to Javascript, which is an entirely different class of language. Javascript is a scripting language (as is Python), and learning Java will mean you understand Javascript reasonably well. The difference is between scripting languages and normal programming languages are outside the scope of this article, but as large generalization scripts are generally used for automated tasks while programs are used interactively by users. This is not totally true, as both types of language are used for both tasks and most web programs are built in Javascript.

As for the actual language you pick, it is entirely up to you. Some may choose the traditional beginner languages or be brave and experiment with Java. Some of you may already have your eye on a language or fancy one of the more specialist languages like Scheme or Prolog. Whatever your choice, the way you will learn how to program is the same.


What IDEs ( Integrated Development Environment ) is best?

Many of the purists say that IDEs are a bad idea, and are packed with unnecessary tools and menus that take up disk space and time to learn. While this is true, I feel that an IDE is definitely worthwhile. Many people offer free IDEs, such as Eclipse and Netbeans, for the more popular languages. There is also Visual Studio, which I mentioned previously; it is very intuitive, very powerful and it supports many languages (much as Netbeans and Eclipse do). If you chose to use Java I would suggest Netbeans, as there is a packaged version of Netbeans with the JDK (Java Development Kit). Most languages need an SDK (Software Development Kit) to work with them, and getting it installed properly and linked to the IDE is often the hardest part of the procedure. Visual Studio already comes with the development kits set up, which makes life easier, but other languages like Java and Python can be quite hard to set up properly. This is why I suggested the Netbeans + JDK bundle for those experimenting with Java, as it handles the complex set up for you, which will save you hours of suffering.

There are, in my opinion, three major advantages to using a fully featured IDE. Firstly, they are usually extensible, meaning that there are many free plug-ins that could make your life a lot easier when you get a little more advanced. Secondly, and most importantly, is the ease with which an IDE allows you to debug your code. Most IDEs let you set breakpoints in the code, which will make the program stop when it gets to that point and let you step through it line by line so you can examine the contents of all the variables at any time. (For those of you who do not know what a variable is, I will briefly explain. A variable is a bit like a train station locker. You ask for one big enough to hold what you want to store, and if what you want to store is the right shape, it can be stored there. When you write a program, any data you want to store temporarily will be held in one of these until you are done with it.) As the old programming saying goes, if you have not found any bugs, you are not looking hard enough. Almost no non-trivial program will work the first time, and trying to work out where the problem lies without the use of a debugger is a pain I would not wish on anyone. Finally, an IDE will often give you advice on how to fix issues in the code. This can be very useful for fixing bugs and saves you having to resort to Google every other minute.

Learning Another Language

Once you have learned one language, whatever it may be, the most valuable thing you will have learned is all the keywords for searches. When you want to do something in a new language, you need only search for what you want to do and the language name. However, by now you will know the names used to refer to what you want to do, allowing your searches to be more effective and yield examples and answers much more quickly. As the fundamentals of programming are mostly the same, regardless of the language you use, you will hopefully be able to guess at the meaning of most of the code much more effectively once you locate an example, allowing you to pick up most of the language very quickly indeed.

Limits

One thing that all new programmers must come to term with is the amount of time learning a programming language takes. Although when you have become an expert you will be able to write many programs quickly, you must remember that many programs have taken whole teams of expert developers years to create. So it is important to understand that knowing a programming language or even several is not enough to write some of the more complex programs you have seen. Don't look upon this new hobby as a way to save yourself a lot of money, as writing your own version of most of the programs that you need to pay for now will be out of your reach.

The most important thing that a new programmer needs to know is that the "Learn Programming in 24 hours" sort of books is simply not true. A more accurate title would be "Learn Programming in 10,000 hours". If you put 24 hours or a week into learning a language you will not be creating the next Windows or a new, state of the art game. It is possible to learn to write a program in 10 minutes, and really all you need to learn a new language is your favorite search engine, but you will not be an expert. The only way to become an expert is much like learning the violin; the answer is practice, practice, and practices some more.

Practice makes a man perfect
More Code »

Friday, February 15, 2019

Program to check a letter is vowel or consonant in java


Hello Friends! Welcome to programming shortcut
Today will discuss:
--> Program to find whether the alphabet is a vowel or consonant  in java or
--> java program to check vowel or consonant using a switch or
--> program to check an alphabet is a vowel or consonant in java or
--> Program to find whether the letter is a vowel or consonant  in java or
--> program to check a letter is a vowel or consonant in java


import java.util.Scanner;
public class Check_letter_to_vowel_or_consonant {
    public static void main(String[] args) {
       String ch;
       Scanner c = new Scanner(System.in);
       System.out.println("Enter letter to check vowel or consonant:");
       ch = c.next();
       switch(ch){
           case "a":
           case "e":
           case "i":
           case "o":
           case "u":
           case "A":
           case "E":
           case "I":
           case "O":
           case "U":
           System.out.println("The alphabet is a vowel");
           break;
           default:
           System.out.println("The alphabet is a consonant");
       }
    }
}



Output:

   First, run:
   Enter letter to check vowel or consonant:
   a
   The alphabet is a vowel

   Second-time run:
   Enter the alphabet :
   d
   The alphabet is a consonant

Explanation: In this programming, we use the Switch case to check an alphabet or a letter is a vowel or consonant


Hello, Friend We first write the program and compile them and run the program to check compiler error or run time error.
Please share the site and comment on your ideas and your suggestions. All suggestion was all welcome.
If any question or doubt in the programming please mention the comment.
Thank yours very much. 
More Code »

Monday, February 4, 2019

Decimal to binary in java with explanation

Hello Friends! Welcome to Programming Shortcut only programming,
Today we'll discuss how to convert a decimal to binary in java. there are two methods to convert decimal to binary:

1. Decimal to binary in java with array using while loop,

2. Decimal to binary in java without array using while loop.


Decimal to binary in java


import java.util.Scanner;
public class DecimaltoBinary  {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int a[] = new int[1000];
        System.out.println("Enter a Decimal number to convert binary");
        int decimalnum = in.nextInt();
        int temp = decimalnum; //the taken number to save take temp variable.
        int n = 0;
        while (temp > 0) { // checking the number to till '0'
            int rem = temp % 2; // taking remainder of number
            temp = temp / 2; // after taking remainder update the number
            a[n] = rem;  // store the remainder into a array
            n++;
        }

//print the array in reverse order
        System.out.print("The binary of " + decimalnum + " is: ");
        for (int i = n - 1; i >= 0; i--) {
            System.out.print(a[i]);
        }
        System.out.println("\n");
    }
}

Output:
Enter a Decimal number to convert binary
23
The binary of 23 is: 10111


Decimal to binary in java without array


import java.util.Scanner;
public class DecimaltoBinary  {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("Enter a Decimal number to convert binary");
        int num = input.nextInt();
        int n = num;
        String temp = "";
        while (n > 0) {
            int rem = n % 2;
            n = n / 2;
            temp = temp + rem;
        }
        String bin = new StringBuffer(temp).reverse().toString();

        System.out.println("The binary number of " + num + " is: " + bin);
    }
}

Output:
Enter a Decimal number to convert binary
24
The binary number of 24 is: 11000

Note: if adding in the String value store in the last of string value

 For example:
 String frist= "Programming";
 String last="Shortcut";
 String name= frist+last;
 System.out.println(name);

 output: ProgrammingShotcut

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

Short name by java program

Hello Friends, Welcome to my blog

Today will write a program to the short name by java program, this problem is also asking in many ways they are following:
 1. Java Program to Convert a Person Name in Abbreviated.
 2. wap to print the short name of the user.
 3. Java program to convert full name to short name.
 4. Java program to a short name.
 5. Abbreviation of Java programming language.

 Problem:-
    Enter Name: Anant Deep Vishwakarma
        Output: A. D. Vishwakarma

 Solutions:-
    1. Store Name in a name String.
    2. Split Name String and Store to a temp string array.
    3. Find temp string array length store value in other variables.
    4. Take a loop to store all value to expect the last name and print the first character by value with
       dot or abbreviation.
    5. then print the last value of temp string all Character

 Explain:
    For example a store name 'Anant Deep Vishwakarma'in a name string and then split value into temp string array as temp[0]='Anant', temp[1]='Deep' and temp[2]='Vishwakarma', after that count length of temp string array and use loop to left the last index value last name 'Vishwakarma', in loop print first char of every index value within loop. in the last print last index of program

Best java program example:

    import java.util.*;
    class SName
    {
     public static void main(String[] args)
        {
            String n;
            Scanner c=new Scanner(System.in);
            System.out.print("Enter the user name:");
            n=c.nextLine();
            String [] t=n.split(" ");
            int l=t.length;
            System.out.print("Your Short name:");
            for(int i=0;i             {
                System.out.print(t[i].charAt(0)+".");
            }
            System.out.print(t[l-1]);
         }
    }
     
I hope you understand the program is any query please comment below your query I reply your questions soon.
Bye..
       
More Code »

Java program to perform sum of digits until single digit is obtained

 Hello Friends!
 Today will discuss do while loop with an example, how to make a program in java by do-while loop, do while loop in java program an example with explanation.
 Write a program in java to find the sum of digits of a number until the sum is reduced to 1 digit.
 For example:
  The number is 538769.
  Then 5+3+8+7+6+9=38
  3+8=11
   11=2

Finding sum of digits of a number until sum becomes single digit java program


import java.util.Scanner;
public class do_while {
   public static void main(String[] args){
    long num,dig,sum;
    Scanner in =new Scanner(System.in);
System.out.print("Enter a number :");
    num=in.nextLong();
    System.out.println("");
System.out.print(num);
do{
        sum = 0;
        while(num!=0)
{
dig=num%10;
            sum+=dig;
            num/=10;
}
        System.out.print("->"+sum);
        num=sum;
}while(num/10!=0);
   }
}
Output: Enter a number : 538769
        538769->38->11->2

Explanation :

    do{
/* 1: program code */
}while(num/10!=0);
        The Above Condition is not exited while a number is more than one digit.
     
/* 1: program code */
while(num!=0)
{
dig=num%10;
sum+=dig;
num/=10;
}
     Here we use program code to find a sum of digit then the given program exapmle is for "Sum of digits of a number until the sum is reduced to 1 digit"

So we find Your Program

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

Java program to reverse a number


Hello friends! welcome to my blog
Today will discuss the basic concept and simplest way to how to reverse a number in java by programming and how to make program for reverse of a number without array in java programming. How to how to count number of digit in a number in java programming, write a program to count number of digit in java

Write a program to reverse a number


import java.util.Scanner;
public class reverse{
public static void main(String[] args){
int n, r=0,d;
    Scanner in =new Scanner(System.in);
    System.out.println("Enter the number");
n=in.nextInt();
System.out.println("Number befour reverse= " +n);
while(n>0){
d= n%10;
r= r*10+d;
n=n/10;
}
System.out.println("Number After reverse= "+r);
}
}


Output: Enter the Number
        1234
Number befour reverse= 1234
Number After reverse= 4321

Write a program to count no of digit of a number


import java.util.Scanner;
public class count{
public static void main(String[] args){
int n, c=0,d;
    Scanner in=new Scanner(System.in);
    System.out.println("Enter the number");
n=in.nextInt();
while(n>0){
d= n%10;
n=n/10;
c++;
}
System.out.println("The entered number has "+ d +"digit");
}
}


Output: Enter the Number
            1234
   The entered number has 4 digit

 

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!
More Code »

sum and product of digit program in java

Hello Friends! Welcome to my blog
Today We will Discus about how to calculate sum of digit and product of digit using while loop of a number in java programming language
The sum of digit of a number is added every digit of number
For example
a number is 8554 then sum of digit is 8+5+5+4=22
And product of digit of a number is multiplication of each digit
For Example
a number is 4581 then product of digit is 4*5*8*1=160
See programming Example:


java program find to sum of digits




import java.util.Scanner;
public class sum_of_digit {
public static void main(String[] args) {
int n, d, s = 0;
Scanner in = new Scanner(System.in);
System.out.println("enter the number");
n = in.nextInt();

while (n > 0) {
d = n % 10;
s = s + d;
n = n / 10;
}
System.out.println("The sum of digit 458"+s);
}
}


Output:
enter the number
8554
The sum of digit 22


java program to find product of digits



import java.util.Scanner;
public class product_of_digit {
public static void main(String[] args) {
int n, d, p = 1;
Scanner in = new Scanner(System.in);
System.out.println("enter the number");
n = in.nextInt();

while (n > 0) {
d = n % 10;
p = p * d;
n = n / 10;
}
System.out.println("The product of digit "+ p);
}
}


Output:
enter the number
4581
The product of digit 160

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

More Code »

Switch case program in java

Hello Friends, Welcome to my blog
Today i will dicuss you how to make switch case program in java . switch case is mulit way conditional statement that work like if else nested loop, .
What is switch Case?
Switch case is a multi-way conditional statement. It Works like as if else if nested conditional statement.But the Advantage of using Switch case over if else if nested conditional statement Management of switch case is easy

See Switch case example below that how work switch statement:

switch case program in java

import java.util.Scanner;
public class switchdemo {

    public static void main(String args[]) {
        double a, b, r;
        String c;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter two Numbers to Calculate");

        a = in.nextDouble();
        b = in.nextDouble();
        System.out.println("Please Select a oprtater +, -, *, /");
        c = in.next();
        switch (c) {
            case "+":
                r = a + b;
                System.out.println(a + " + " + b + " = " + r);
                break;
            case "-":
                r = a - b;
                System.out.println(a + " - " + b + " = " + r);
                break;
            case "*":
                r = a * b;
                System.out.println(a + " * " + b + " = " + r);
                break;
            case "/":
                r = a / b;
                System.out.println(a + " / " + b + " = " + r);
                break;
            default:
                System.out.println("Enter valid operator\n");
                break;
        }
    }
}


Output: Enter two Numbers to Calculate
        5
        4
        Please Select a oprtater +, -, *, /
        *
        5.0 * 4.0 = 20.0


     
I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please any query email programmingshortcut@gmail.com

Please comment your experience about this post,
Thank You!

      
More Code »

Program to swap two numbers in java

Hello friends! Welcome to my blog
Here we discuss how to swap two numbers in java language and there are two methods to swap two numbers in java

1. swap two numbers without using third variable in java.

2. swap two numbers with using third variable in java.

See Example below

Swap two numbers without temp in java


import java.util.Scanner;
public class swap_without {
    public static void main(String[] args) {
       int a ,b;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the two number");
        a=in.nextInt();
        b=in.nextInt();
        System.out.println("Number before Swap:\n a="+a+"\n b="+b);
        a=a+b;
        b=a-b;
        a=a-b;
        System.out.println("Number After Swap:\n a="+a+"\n b="+b);
    }
}


Enter the two number
4
6
Number before Swap:
 a=4
 b=6
Number After Swap:
 a=6
 b=4



Swap two numbers in java


import java.util.Scanner;
public class swap {
    public static void main(String[] args) {
        int a ,b;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the two number");
        a=in.nextInt();
        b=in.nextInt();
        System.out.println("Number Before Swap:\n a="+a+"\n b="+b);
        int temp=a;
        a=b;
        b=temp;
        System.out.println("Number After Swap:\n a="+a+"\n b="+b);
 
    }
}


Enter the two number
4
7
Number Before Swap:
 a=4
 b=7
Number After Swap:
 a=7
 b=4


I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about Java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcuts

Please share your experience about this post,
Thank You!
More Code »

Fibonacci series programming in java

Hello friends! Welcome to my website

Program to generate Fibonacci series programming in java. How to use for loop in java language with example
In this Fibonacci series, each number is a sum of the previous two numbers. fibonacci series programming java, Fibonacci series java programming, Fibonacci series java code in java session

How to print Fibonacci series programming in java


import java.util.Scanner;
public class fibonacci {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        long x, y, z;
        int i, n;
        x = 0;
        y = 1;
        System.out.print("Enter the number of terms : ");
        n = c.nextInt();
        System.out.print(y+", ");
        for (i = 1; i             z = x + y;
            System.out.print(z+", ");
            x = y;
            y = z;
        }
        System.out.print(" ");
    }
}


Output: Enter the number of terms: 10
        1, 1, 2, 3, 5, 8, 13, 21, 34, 55,


I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!
More Code »

Even and odd numbers list betwwen 1 to n in java

Hello friends! Welcome to my website

This session shows how to print all even and odd numbers list between 1 to n by oops concepts in java
This java language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.


Print all even numbers between 1 to n in Java 


import java.util.Scanner;
class test1 {
int n;
public void printeven(int n) {
int i =0;
while ( i if(i%2==0){
System.out.print(i+" ");
}
i++;
}
}
}
public class evenlist {
public static void main(String[] args) {
test1 o = new test1();
Scanner c= new Scanner(System.in);
System.out.print("Enter a Number till want list:");
o.n=c.nextInt();
System.out.println("All Even Number list");
o.printeven(o.n);
}
}


Output:    Enter a Number till want list: 20
All Even Number list
0 2 4 6 8 10 12 14 16 18



Print all odd numbers between 1 to n in Java 


import java.util.Scanner;
class test1 {
int n;
public void printSum(int n) {
int i = 0;
while (i if (i % 2 == 1) {
System.out.print(i + " ");
}
i++;
}
}
}
public class even_and_odd {
public static void main(String[] args) {
test1 o = new test1();
Scanner c = new Scanner(System.in);
System.out.print("Enter a Number till want list: ");
o.n = c.nextInt();
System.out.println("All Odd Number list");
o.printSum(o.n);
}
}


Output:  Enter a Number till want list: 20
All Odd Number list
1 3 5 7 9 11 13 15 17 19

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!

More Code »

Find a number is even or odd number in Java

Hello friends! Welcome to my website

Today We Run a program to check a number is an even number or an odd number in java.
This session is how to check the number is even or odd in Java Programming. Here we show you, how use of For loop in java programming with Example and oops concepts in java
This java language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.

 Find a number is even or odd number in Java Programming?


import java.util.Scanner;
class test5 {
int n;
public void odd_even(int n) {

if ((n % 2) == 0) {
System.out.println(n + " is an Even Number");
} else {
System.out.println(n + " is a Odd Number");
}
}
}
public class oddandeven {

public static void main(String args[]) {
test5 o = new test5();
Scanner c = new Scanner(System.in);
System.out.print("Enter a Number to check Even or odd: ");
o.n = c.nextInt();
o.odd_even(o.n);
}
}


Output: Enter a Number to check Even or odd: 2
              2 is an Even Number
             Enter a Number to check Even or odd: 3
             3 is an Odd Number

Note: This program is run 2-time output.

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut

Please share your experience about this post,
Thank You!

More Code »
Older Posts Home

About Programming Shortcut

This is a programming learning website that can help you learn and when your write your programming code. And all programming code is compiled run programming code in the following programming language C, c++, Java, php and Javascript Languages. find your programming read, understand the programming then copy and past and run your program and save your golden time to typing the program becuse you learn more in leas time. All Programming is codeing is ease to understand the programming