
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 70 Articles for Java Technologies

231 Views
public class RegexOccur { public static void main(String args[]) { String str = "java is fun so learn java"; String findStr = "java"; int lastIndex = 0; int count = 0; while(lastIndex != -1) { lastIndex = str.indexOf(findStr,lastIndex); if(lastIndex != -1) { count ++; lastIndex += findStr.length(); } } System.out.println(count); } }Output2

4K+ Views
In this article. we will learn about break, continue, and label in Java loop. There are cases when you would want to manage the flow of your loop, that is, skip some iterations or terminate the loop altogether. This is where break, continue, and label statements are used. Break Statement A break statement interrupts the normal execution of a loop and causes it to exit before being completed. The loop will terminate and the flow of control will transfer to the next statement immediately following the loop, when the break function is called. It can be used in any loop statement, ... Read More

664 Views
Java programming language provides following types of decision making or branching statements.Java programming language provides following types of decision making statements.Sr.No.Statement & Description1if statementAn if statement consists of a boolean expression followed by one or more statements.2if...else statementAn if statement can be followed by an optional else statement, which executes when the boolean expression is false.3nested if statementYou can use one if or else if statement inside another if or else if statement(s).4switch statementA switch statement allows a variable to be tested for equality against a list of values.

1K+ Views
Following program is using labeled for loops.ExampleLive Demopublic class Tester { public static void main(String args[]) { first: for (int i = 0; i < 3; i++) { for (int j = 0; j< 3; j++){ if(i == 1){ continue first; } System.out.print(" [i = " + i + ", ... Read More

4K+ Views
Yes. Java supports labeled statements. You can put a label before a for statement and use the break/continue controls to jump to that label. ExampleSee the example below.Live Demopublic class Tester { public static void main(String args[]) { first: for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++){ if(i == 1){ continue first; ... Read More

5K+ Views
| is a bitwise operator and compares each operands bitwise.It is a binary OR Operator and copies a bit to the result it exists in either operands.Assume integer variable A holds 60 and variable B holds 13 then (A | B) will give 61 which is 0011 1101.Whereas || is a logical OR operator and operates on boolean operands. If both the operands are false, then the condition becomes false otherwise it is true. Assume boolean variable A holds true and variable B holds false then (A && B) is true.| is to be used during bitwise operations and || is useful during logical operations.

8K+ Views
& is a bitwise operator and compares each operand bitwise.It is a binary AND Operator and copies a bit to the result if it exists in both operands.Assume integer variable A holds 60 and variable B holds 13 then (A & B) will give 12 which is 0000 1100.Whereas && is a logical AND operator and operates on boolean operands. If both the operands are true, then the condition becomes true otherwise it is false. Assume boolean variable A holds true and variable B holds false then (A && B) is false.& is to be used during bitwise operations and && is useful during logical operations.

614 Views
The unary operator works on a single operand. Following are the examples of unary operators supported in java. Assume A = 60 and B = 20.OperatorDescriptionExample~ (bitwise compliment)Binary One's Complement Operator is unary and has the effect of 'flipping' bits.(~A ) will give -61 which is 1100 0011 in 2's complement form due to a signed binary number.++ (Increment)Increases the value of operand by 1.B++ gives 21-- (Decrement)Decreases the value of operand by 1.B-- gives 19