Fill an array with specific values in Julia | Array fill() method Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The fill() is an inbuilt function in julia which is used to return an array of specified dimensions filled with a specific value passed to it as parameter. Syntax: fill(Value, Dimension)Parameters: Value: To be filled in the arrayDimension: Required size of the array Returns: It returns an array of nXn dimension with each element as the specified value. Example: Python # Julia program to illustrate # the use of Array fill() method # Creating a 1D array of size 4 # with each element filled with value 5 A = fill(5, 4) println(A) # Creating a 2D array of size 2X3 # with each element filled with value 5 B = fill(5, (2, 3)) println(B) # Creating a 3D array of size 2X2X2 # with each element filled with value 5 C = fill(5, (2, 2, 2)) println(C) Output: Array fill!() method fill!() method works exactly like fill() method i.e. it fills an array with a specific value passed to it as argument, but the only difference is that, fill!() method takes an existing array as argument and fills it with a new specified value. While the fill() method takes array dimensions and creates a new array of its own. Syntax: fill!(Array, Value)Parameters: Array: It is the array of specified dimension.Value: It is the value to be filled in the array. Returns: It returns the array passed to it as argument with the specified value filled at each index. Example: Below code is using one dimension array of 3 elements. Python # Julia program to illustrate # the use of Array fill() method # Creating a 1D array of size 5 Array1 = [1, 2, 3, 4, 5] # Filling array with fill!() Array1 = fill!(Array1, 10) println(Array1) # Creating a 2D array of size 2X2 Array2 = [1 2; 3 4] Array2 = fill!(Array2, 10) println(Array2) # Creating a 3D array of size 2X2X2 Array3 = cat([1 2; 3 4], [5, 6; 7 8], dims=3) Array3 = fill!(Array3, 10) println(Array3) Output: Comment More infoAdvertise with us Next Article Fill an array with specific values in Julia | Array fill() method K Kanchan_Ray Follow Improve Article Tags : Julia julia-array Similar Reads Learn Free Programming Languages In this rapidly growing world, programming languages are also rapidly expanding, and it is very hard to determine the exact number of programming languages. Programming languages are an essential part of software development because they create a communication bridge between humans and computers. No 9 min read For loop in Julia For loops are used to iterate over a set of values and perform a set of operations that are given in the body of the loop. For loops are used for sequential traversal. In Julia, there is no C style for loop, i.e., for (i = 0; i Syntax: for iterator in range statements(s) end Here, 'for' is the keywo 2 min read Julia Dictionary Dictionary in Julia is a collection of key-value pairs, where each value in the dictionary can be accessed with its key. These key-value pairs need not be of the same data type, which means a String typed key can hold a value of any type like Integer, String, float, etc. Keys of a dictionary can nev 7 min read Vectors in Julia Vectors in Julia are a collection of elements just like other collections like Array, Sets, Dictionaries, etc. Vector are different from Sets because vectors are ordered collections of elements, and can hold duplicate values, unlike sets which require all the elements to be unique. Vectors are one-d 5 min read Printing Output on Screen in Julia Julia provides many methods of printing output on the screen. The Julia program starts with an interactive REPL (Read/ Evaluate /Print / Loop) as default. R: Reads what was typed;E: Evaluates the typed expression;P: Prints the return value;L: Loops back and repeats it ; It helps in outputting the r 3 min read String concatenation in Julia String concatenation in Julia is a way of appending two or more strings into a single string whether it is character by character or using some special characters end to end. There are many ways to perform string concatenation. Example: Input: str1 = 'Geeks' str2 = 'for' str3 = 'Geeks' Output: 'Gee 2 min read Opening and Reading a File in Julia File handling in Julia is achieved using functions such as open(), read(), and close(). There are many ways to read the contents of a file like readline(), readlines() and just read(). open(): To open a file existing in an absolute path, provided as the parameter.  read(): Read the contents of the f 4 min read Julia Language Introduction Julia is a high-level open-source programming language, developed by a group of 4 people at MIT. Julia is a dynamic, high-performance programming language that is used to perform operations in scientific computing. Similar to R Programming Language, Julia is used for statistical computations and dat 4 min read Arrays in Julia Arrays in Julia are a collection of elements just like other collections like Sets, Dictionaries, etc. Arrays are different from Sets because arrays are ordered collection of elements, and can hold duplicate values, unlike sets which require all the elements to be unique. Arrays are N-Dimensional co 13 min read Operators in Julia Operators in Julia are the mathematical symbols that are used to perform operations on variables and values. These symbols are used to carry out arithmetic and logical computations. Variables on which the operators perform operations are termed as Operands. In other words, we can say that an operato 9 min read Like