Tutorialspoint

Can i refer an element of one array from another array in java?

Can I refer an element of one array from another array in java?
Nikitha N
Answered on 3rd Jan, 2018

Yes, you can:int [] myArray1 = {23, 45, 78, 90, 10}; int [] myArray2 = {23, 45, myArray1[2], 90, 10};But, once you do so the second array stores the reference of the value, not the reference of the whole array. For this reason, any updating in the array will not ... Read More

How to find and replace within a text file using Python?

How do I find the word 'Poetry' and replace it with 'Prose' within the Python text file foo,txt whose contents are given below? ,
Rajendra Dharmkar
Answered on 9th Jan, 2018

The following code does the replacement in the given text file. After the replacement, the text is written to a new text file 'bar.txt'f1 = open('foo.txt', 'r') f2 = open('bar.txt', 'w') for line in f1:     print line     f2.write(line.replace('Poetry', 'Prose')) f2 = open('bar.txt', 'r') for line in f2: ... Read More

What are variable length (Dynamic) Arrays in Java?

What are variable length (Dynamic) Arrays in Java?
Srinivas Gorla
Answered on 3rd Jan, 2018

In Java, Arrays are of fixed size. The size of the array will be decided at the time of creation. But if you still want to create Arrays of variable length you can do that using collections like array list.Exampleimport java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class AddingItemsDynamically { ... Read More

How to create a generic array in java?

How to create a generic array in java?
Abhinanda Shri
Answered on 3rd Jan, 2018

No, we can’t create generic arrays in java.

How to add items to an array in java dynamically?

How to add items to an array in java dynamically?
Ankitha Reddy
Answered on 3rd Jan, 2018

Since the size of an array is fixed you cannot add elements to it dynamically. But, if you still want to do it then, Convert the array to ArrayList object. Add the required element to the array list. Convert the Array list to an array. Example import ... Read More

How to overwrite a specific chunk in a byte array using java?

How to overwrite a specific chunk in a byte array using java?
Abhinaya
Answered on 3rd Jan, 2018

Java provides a ByteBuffer class which allows you to wrap an array into a byte buffer using its wrap() method. Once you did that you can replace the contents of the buffer using the position(): To select the starting position and, put(): To replace the data methods:ExampleLive Demoimport java.nio.ByteBuffer; public ... Read More

How to change array into a list in Java?

How to change array into a list in Java?
Govinda Sai
Answered on 3rd Jan, 2018

Create an ArrayList, use for loop to iterate through the loop. Within the loop add each element of the array to the ArrayList:ExampleLive Demoimport java.util.ArrayList; import java.util.List; public class ArrayToArrayList {    public static void main(String args[]) {       int[] myArray = {20, 30, 45, 58, 96}; ... Read More

How to declare Java array with array size dynamically?

How to declare Java array with array size dynamically?
Ramu Prasad
Answered on 3rd Jan, 2018

To declare array size dynamically read the required integer value from the user using Scanner class and create an array using the given value:Exampleimport java.util.Arrays; import java.util.Scanner; public class PopulatingAnArray {    public static void main(String args[]) {       System.out.println("Enter the required size of the array :: ... Read More

How to define an array size in java without hardcoding?

How to define an array size in java without hardcoding?
Sravani S
Answered on 3rd Jan, 2018

To avoid hard coding you can read the size of the array from the user using command line arguments of the reader classes like Scanner. Then using this value create an array:Exampleimport java.util.Arrays; import java.util.Scanner; public class PopulatingAnArray {    public static void main(String args[]) {       ... Read More

Where should I place JavaScript in an HTML file?

I am new to JavaScript and learning the basics. To add JavaScript to a web page, which tag is to be used and where I should include JavaScript in an HTML web page?
seetha
Answered on 8th Jan, 2018

JavaScript can be implemented using JavaScript statements that are placed within the <script>... </script>. To place JavaScript in an HTML file, use the <script>…</script> tag.You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the ... Read More

How to find whether a browser supports JavaScript or not?

Which HTML tag is to be used in JavaScript to find whether JavaScript is supported by a web browser or not?
vanithasree
Answered on 8th Jan, 2018

To find whether the browser supports JavaScript or nor, use the <noscript> tag. The HTML <noscript> tag is used to handle the browsers, which do recognize <script> tag but do not support scripting. This tag is used to display an alternate text message.Here’s an example, <!DOCTYPE html> <html>    <head> ... Read More

How to detect if JavaScript is disabled in a browser?

How can I give a warning to the users if JavaScript is disabled in a web browser? Which tag is to be used for this purpose?
radhakrishna
Answered on 8th Jan, 2018

To detect if JavaScript is disabled in a web browser, use the <noscript> tag. The HTML <noscript> tag is used to handle the browsers, which do recognize <script> tag but do not support scripting. This tag is used to display an alternate text message.Here’s an example, <!DOCTYPE html> <html>   ... Read More

How to give a warning for Non-JavaScript Browsers?

How can I give a warning to the users if the browser is a non-JavaScript web browser? Which tag is to be used for this purpose?
Giri Raju
Answered on 8th Jan, 2018

To let users know about non-JavaScript web browsers, use the <noscript> tag. The HTML <noscript> tag is used to handle the browsers, which do recognize <script> tag but do not support scripting. This tag is used to display alternate text messageHere’s an example, <!DOCTYPE html> <html>    <head>     ... Read More

How to disable JavaScript in Opera?

JavaScript is enabled in my Opera web browser. What are the steps to be followed if I want to disable JavaScript on my browser?
Sreemaha
Answered on 8th Jan, 2018

To disable JavaScript in Opera, follow the below given steps:Open Opera browser and click on the left. Then click Settings:Now under Search Settings, search javascript.On searching, you will get the following options to disable javascript as shown below:

How to enable JavaScript in Opera?

JavaScript is not enabled in my Opera web browser. What are the steps to be followed if I want to enable JavaScript in my browser?
varma
Answered on 8th Jan, 2018

To enable JavaScript in Opera, follow the below-given steps:Open Opera browser and click on the left. Then click Settings:Now under Search Settings, search javascript.On searching, you will get the following options to allow javascript as shown below:

Advertisements
Loading...
Unanswered Questions View All