Aatul Palandurkar

Posts Tagged ‘Java Source Code


  • How to use switch case in Java?
  • How to use switch case with string in Java?
  • How to pass string literals in switch case in Java?


Source Code:

public class SwitchWithStringExample

public static void main(String[] args)
String str = "two";
case "one":
case "two":
case "three":
System.out.println("no match");
} // switch close
} // main close
} // class close


Steps to run above Java code:

Consider that we have saved code at C drive (c:\>) and the file is saved as SwitchWithStringExample.java

  1. Compilation : c:\> javac SwitchWithStringExample.java
  2. Interpretation : c:\> java SwitchWithStringExample





We conduct Java Training and Workshop for Corporates and College Students, if interested, please write to us on kloudsancyber@gmail.com


Aatul Palandurkar
International Trainer, and Author, NetBeans Dream Team Member


Free Source Code

Free Source Code

Objective :

  • How to check your operating system by programming?
  • How to check your operating system by Java programming?
  • Write Java program to check operating system & its version

Hi folks,

Hey guys, if you want to know which operating system you are using & its version, there are 2 ways to do it as follows;

  • Using Command Prompt
  • Using Programming

1. Using Command Prompt

  • Go to Start Menu
  • Go to Run
  • Type cmd & press Enter/return. Command Prompt will open.
  • Type ver & press Enter/return, you will get the Name of your OS & its Version that you are using
Here I have used, ver command one of the DOS commands which returns Name of Operating System and its version.

2. Using Programming

Here we are using a Java Program to find the operating system you are using & its version :
package com.si.java.utility.os;

* Language : Java
* File : MyOS.java
* Date : Tuesday, October 5, 2010
* @author Atul Palandurkar
* Email : atul.palandurkar@gmail.com
* Website : www.shardainfotech.com
* Blog : https://atulpalandurkar.wordpress.com

public class MyOS
public static void main(String[] arg)
//To find the name of operating system.
String myOS = System.getProperty("os.name");
System.out.println("Operating System : " + myOS);

//To find the version of operating system.
String myOSVersion = System.getProperty("os.version");
System.out.println("Version : " + myOSVersion);
So, what are you waiting for?
Use it to create various system utilities & have fun.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 13,238 other followers




%d bloggers like this: